-
Notifications
You must be signed in to change notification settings - Fork 48
Yasmin-Leaves #37
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?
Yasmin-Leaves #37
Conversation
…paces and white spaces)
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, but you didn't reverse in place and didn't handle extra spaces in the output. Otherwise not bad. Check out my comments and let me know if you have questions.
| # Time complexity: ? | ||
| # Space complexity: ? | ||
| # Time complexity: o(n) | ||
| # 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.
You are doing my_sentence.split which creates a new array of equal size to the string. So... This is O(n) space complexity.
You were asked to do this in place.
| end | ||
| # binding.pry | ||
| # print words | ||
| final_word = words.join(" ") |
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, but you assume each word is separated by one space. That's not necessarily true.
| # 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.
Since you do .split this has space complexity of 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 bubblesort.
…paces and white spaces)
Sorting & Reverse Sentence