-
Notifications
You must be signed in to change notification settings - Fork 39
Sockets - Kirsten #9
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?
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.
Very nicely done. See my inline comments, but this is outstanding work. Check a little bit on your big-O as you missed some of the overhead of some of the built-in functions, something most people do.
|
|
||
| # Time complexity: ? | ||
| # Space complexity: ? | ||
| # Time complexity: O(n), where n is the length of the string |
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 is not in place since you create a new string.
Think about making a helper which takes the string, a left index and right index. The base case is when left_index >= right_index Each recursive call you swap the characters at left_index or right_index and then make a recursive call with the string, and left_index + 1 and right_index -1.
| return reverse_helper(s, i, j) | ||
| end | ||
|
|
||
| def reverse_helper(s, i, j) |
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.
Really great!
| # Space complexity: ? | ||
| # Time complexity: O(n), where n is the input number | ||
| # Space complexity: O(n), where n is the input number | ||
| def bunny(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.
👍
| # Space complexity: ? | ||
| # Time complexity: O(n), where n is the size of the input string | ||
| # Space complexity: O(n), where n is the size of the input string | ||
| def nested(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.
👍
|
|
||
| end | ||
|
|
||
| # Time complexity: O(n), where n is the length of the input array |
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 is actually O(n^2) since you create a new array with each recursive call.
| # Space complexity: ? | ||
| # Time complexity: O(n), where n is the length of the string | ||
| # Space complexity: O(n), where n is the length of the string | ||
| def is_palindrome(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.
👍
| # Space complexity: ? | ||
| # Time complexity: O(log10(n)), where n is the smallest input number | ||
| # Space complexity: O(log10(n)), where n is the smallest input number | ||
| def digit_match(n, m) |
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.
👍
No description provided.