Open
Conversation
CheezItMan
reviewed
Oct 9, 2019
CheezItMan
left a comment
There was a problem hiding this comment.
Nice work, you hit the learning goals here. Check out my comments and let me know if you have any questions.
| # A method to reverse the words in a sentence, in place. | ||
| # Time complexity: ? | ||
| # Space complexity: ? | ||
| # Time complexity: O(n ^2) because lines 47-55 contain a nested loop. |
There was a problem hiding this comment.
Actually since start_position jumps to the end of the reversed word after a reversal, this is O(n)
| # Time complexity: ? | ||
| # Space complexity: ? | ||
| # Time complexity: O(n ^2) because lines 47-55 contain a nested loop. | ||
| # Space complexity: ? O(n) because of the empty_index_positions array from lines 33 - 38 |
There was a problem hiding this comment.
I would say O(m) where m is the number of words, but yet. Could you instead do this with O(1) space complexity?
Comment on lines
+20
to
+25
| if my_sentence[i].length < comparison_word.length | ||
| puts my_sentence[i] | ||
| puts comparison_word | ||
| swap(my_sentence, i, j ) | ||
| comparison_word = my_sentence[j] | ||
| end |
There was a problem hiding this comment.
This is an interesting sort, it's not one of the standard sorts but does sort elements. It does work however.
| # Time complexity: ? | ||
| # Space complexity: ? | ||
| # Time complexity: O(n ^ 2) | ||
| # Space complexity: ? O(n) because of splitting the string at the beginning of the method |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Sorting & Reverse Sentence