-
Notifications
You must be signed in to change notification settings - Fork 47
Daniela - Leaves #42
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?
Daniela - Leaves #42
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.
You're absolutely right something is better than nothing. You don't have many methods here, but factorial and reverse_in_place are well done.
| # Space complexity: ? | ||
| # Time complexity: O(n), because of the size of the stack (number of methods that is accumulated in the stack to run) | ||
| # Space complexity: O(n), because of the size of this stack | ||
| def factorial(n) |
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.
👍
| while i < j | ||
| memo = s[i] | ||
| s[i] = s[j] | ||
| s[j] = memo | ||
|
|
||
| i += 1 | ||
| j -= 1 | ||
| end |
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.
A while loop, this is supposed to be recursive method 🤔
| # Time complexity: O(n) ~ n/2 as increasing and decreasing both pointer in same call | ||
| # Space complexity: O(n), n/2 recursive calls, | ||
| # because both pointers are moving each time the method is called | ||
| def reverse_inplace(s, i = 0, j = s.length - 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.
👍 Great work!
Better something than nothing...