-
Notifications
You must be signed in to change notification settings - Fork 48
Bri - Leaves #39
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?
Bri - Leaves #39
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.
Well done! You hit all the learning goals here. Take a look at my comments and let me know if you have questions
| def reverse_word(string, start, ending) | ||
|
|
||
| i = start | ||
| j = ending | ||
|
|
||
| while i < j | ||
| temp = string[i] | ||
| string[i] = string[j] | ||
| string[j] = temp | ||
|
|
||
| i += 1 | ||
| j -= 1 | ||
| end | ||
| 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.
Love the helper method!
| def reverse_sentence(my_sentence) | ||
| raise NotImplementedError | ||
| # Time complexity: O(N) | ||
| # Space complexity: O(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.
Since you're not making another string or array, this is actually O(1) space complexity.
| # Time complexity: O(N^2) | ||
| # Space complexity: O(N) | ||
|
|
||
| def sort_by_length(my_sentence) |
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.
Nice Bubblesort!
Sorting & Reverse Sentence