-
Notifications
You must be signed in to change notification settings - Fork 47
branches - vi #45
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
base: master
Are you sure you want to change the base?
branches - vi #45
Conversation
CheezItMan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not bad, you do have some issues with space complexity and one bug in the matching parens, but nice work overall.
| # Space complexity: ? | ||
| # Time complexity: O(n) | ||
| # Space complexity: O(n) | ||
| def reverse(s) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
| raise NotImplementedError, "Method not implemented" | ||
| # Time complexity: O(n) | ||
| # Space complexity: O(1) | ||
| def reverse_inplace(s, i = 0, j = -1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The space complexity is O(n) due to the system stack
| raise NotImplementedError, "Method not implemented" | ||
| # Time complexity: O(n) | ||
| # Space complexity: O(n) | ||
| def bunny(n, ears = 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works although I was expecting something like:
def bunny(n)
return 0 if n == 0
return 2 + bunny(n-1)
end| if s.length.odd? | ||
| return false | ||
| elsif low < high | ||
| if s[low] != "(" && s[high] != ")" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small bug
| if s[low] != "(" && s[high] != ")" | |
| if s[low] != "(" || s[high] != ")" |
| # Time complexity: ? | ||
| # Time complexity: O(n) | ||
| # Space complexity: ? | ||
| def search(array, value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
|
|
||
| # Time complexity: O(n) | ||
| # Space complexity: O(1) | ||
| def is_palindrome(s, i = 0, j = -1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 But the space complexity is O(n)
No description provided.