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

Water - Kayla Johnson #39

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Water - Kayla Johnson #39

wants to merge 6 commits into from

Conversation

Kaylaj89
Copy link

@Kaylaj89 Kaylaj89 commented Nov 4, 2020

No description provided.

Copy link

@CheezItMan CheezItMan left a comment

Choose a reason for hiding this comment

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

You didn't quite finish them all and you didn't manage to do reverse in place. However the other methods are pretty well done although several lack space/time complexity. Take a look at my comments and let me know what questions you have.

Comment on lines +3 to 5
# Time complexity: O(n) ['n' being the number of times factorial computation has to be implemented until n reaches 0]
# Space complexity: 0(n) ['n' being the number of function calls on the stack]
def factorial(n)

Choose a reason for hiding this comment

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

👍

Comment on lines +12 to +14
# Time complexity: O(n^2)
# Space complexity: O(n^2)
def reverse(s, i = 1)

Choose a reason for hiding this comment

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

👍

Comment on lines 21 to 23
# Time complexity: ?
# Space complexity: ?
def reverse_inplace(s)

Choose a reason for hiding this comment

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

⚠️ This is unfortunately not in place. Can you do this more easily with this method signature?

Suggested change
# Time complexity: ?
# Space complexity: ?
def reverse_inplace(s)
# Time complexity: ?
# Space complexity: ?
def reverse_inplace(s, low = 0, high = s.length - 1)

Comment on lines +29 to 31
# Time complexity: O(n)
# Space complexity: O(n)
def bunny(n)

Choose a reason for hiding this comment

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

👍

Comment on lines 36 to 38
# Time complexity: ?
# Space complexity: ?
def nested(s)

Choose a reason for hiding this comment

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

👍 Time/space complexity?

Comment on lines 47 to 49
# Time complexity: ?
# Space complexity: ?
def search(array, value)
raise NotImplementedError, "Method not implemented"
def search(array, value, i = 0)

Choose a reason for hiding this comment

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

👍 Time/space complexity?

puts "Sorry, I couldn't figure this one out!"

Choose a reason for hiding this comment

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

Understood, does this help?

Suggested change
puts "Sorry, I couldn't figure this one out!"
if n == 0 || m == 0
return n % 10 == m % 10 ? 1 : 0
end
new_n = n / 10
new_m = m / 10
if n % 10 == m % 10
# your code

Copy link

@CheezItMan CheezItMan left a comment

Choose a reason for hiding this comment

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

Nice work Kayla, thanks for getting this in. This is outstanding work. Take a look at my comments and let me know what questions you have.

Comment on lines +21 to +23
# Time complexity: O(n) -still has to iterate over every element in string
# Space complexity: O(n) -stack can get very large if string is big
def reverse_inplace_helper(s, start, finish)

Choose a reason for hiding this comment

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

👍 Really nice!

Comment on lines +73 to +75
# Time complexity: O(n)
# Space complexity: O(n)
def digit_helper(n, m, match = 0, place = 0)

Choose a reason for hiding this comment

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

👍 Outstanding!

Comment on lines +56 to +58
# Time complexity: O(n) best case O(1) if item is in index 1?
# Space complexity: O(n) best case O(1) if item is in index 1?
def search(array, value, i = 0)

Choose a reason for hiding this comment

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

👍 Well done!

Comment on lines +45 to 47
# Time complexity: O(n)
# Space complexity: O(n)
def nested(s)

Choose a reason for hiding this comment

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

Due to the slice you're doing, this is O(n^2) for both time/space.

Otherwise 👍

Comment on lines +65 to 67
# Time complexity: O(n) - traversing the whole string
# Space complexity: O(n) -traversing the whole string
def is_palindrome(s)

Choose a reason for hiding this comment

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

Due to the slice this is O(n^2), but otherwise 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants