-
Notifications
You must be signed in to change notification settings - Fork 48
Tiffany C. #40
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?
Tiffany C. #40
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! You even got the reverse_sentence in place. Great work!
Take a look at my comments and let me know if you have questions.
| temp = my_sentence[len - i - 1] | ||
| my_sentence[len - i - 1] = my_sentence[i] | ||
| my_sentence[i] = temp |
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.
Notice that you're reversing substrings multiple times. That makes it a great candidate for a helper method.
| # Time complexity: ? | ||
| # Space complexity: ? | ||
| # Time complexity: O(n^2) | ||
| # Space complexity: O(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.
Technically since you're doing .split this makes a new array and the space complexity is O(n)
| # Space complexity: ? | ||
| # Time complexity: O(n^2) | ||
| # Space complexity: O(1) | ||
| 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 insertion sort!
Sorting & Reverse Sentence