Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Abigail C - Rock #34

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
15 changes: 12 additions & 3 deletions lib/max_subarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,20 @@
def max_sub_array(nums):
""" Returns the max subarray of the given list of numbers.
Returns 0 if nums is None or an empty list.
Time Complexity: ?
Space Complexity: ?
Time Complexity: O(n)
Space Complexity: O(1)
Comment on lines 2 to +6

Choose a reason for hiding this comment

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

👍 Nice work

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

max_sum = nums[0]
curr_sum = nums[0]
Comment on lines +13 to +14

Choose a reason for hiding this comment

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

Nice touch starting them as the 1st element


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

return max_sum

16 changes: 13 additions & 3 deletions lib/newman_conway.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,17 @@
# Space Complexity: ?
def newman_conway(num):
""" Returns a list of the Newman Conway numbers for the given value.
Time Complexity: ?
Space Complexity: ?
Time Complexity: O(N)
Space Complexity: O(N)
"""
Comment on lines 5 to 9

Choose a reason for hiding this comment

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

👍 Well done Abigail.

pass
if num < 1:
raise ValueError("Invalid number")
if num == 1:
return "1"
arr = [ 0, 1, 1]
for i in range(3,num+1):
arr.append(arr[arr[i - 1]] + arr[i - arr[i - 1]])

arr = [str(item) for item in arr ]
return " ".join(arr[1:])