Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions lib/max_subarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ def max_sub_array(nums):
"""

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 Implementations looks great, but what about time and space complexity?

if nums == None:
return 0
if len(nums) == 0:
elif len(nums) == 0:
return 0
pass

all_maxes = nums[0]
max_current_sub = nums[0]

for i in range(1, len(nums)):
max_current_sub = max(max_current_sub + nums[i], nums[i])
all_maxes = max(all_maxes, max_current_sub)

return max_current_sub


14 changes: 13 additions & 1 deletion lib/newman_conway.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,16 @@ def newman_conway(num):
Time Complexity: ?
Space Complexity: ?
Comment on lines 7 to 8
Copy link

@kyra-patton kyra-patton Jun 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 Implementation looks mostly good again here, but what about time and space complexity?

"""
pass
if num < 1:
raise ValueError("Must be a positive number")
if num == 1:
return "1"

current_list = [0, 1, 1]

count = 3
while count <= num:
current_list.append(current_list[current_list[count - 1]] + current_list[count - current_list[count - 1]])
count += 1

return [str(item) for item in current_list]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 To pass the tests, you want to return the newman conway numbers as a string (ex. "0 1 1") instead of a list of strings