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
10 changes: 9 additions & 1 deletion lib/max_subarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,12 @@ def max_sub_array(nums):
return 0
if len(nums) == 0:
return 0
pass

now_max = 0
max_ending_here = nums[0]

for i in range(len(nums)):
now_max = max(nums[i], now_max + nums[i])
max_ending_here = max(max_ending_here, now_max)
return max_ending_here
Comment on lines +13 to +19

Choose a reason for hiding this comment

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

👍 Nicely done. Time/space complexity?


11 changes: 10 additions & 1 deletion lib/newman_conway.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,13 @@ def newman_conway(num):
Time Complexity: ?
Space Complexity: ?
"""
pass
if num == 0:
raise ValueError

if num == 1:
return '1'

sequence = [0, 1, 1]
for i in range(3, num + 1):
sequence.append (sequence[sequence[i - 1]] + sequence[i - sequence[i -1]])
return ' '.join([str(s) for s in sequence[1:]])
Comment on lines +10 to +19

Choose a reason for hiding this comment

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

👍 However time/space complexity?