Skip to content
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

Amanda Ungco- Reverse Sentence #18

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

amandaungco
Copy link

The space complexity for my solution is constant, regardless of the size of the string, the same number of variables are created.

The time complexity of my solution is linear. Each of my helper methods is O(n).

@amandaungco amandaungco changed the title created reverse_sentence by using reverse string and reverse words Amanda Ungco- Reverse Sentence Sep 25, 2018
end
return nil
end

def reverse_words(my_words)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comments as I added to the reverse_words' assignment.

@@ -4,22 +4,6 @@ def reverse_sentence(my_sentence)
return reverse_words(reversed_string)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the string_reverse reverses the input string in place, you don't need to return anything or assign anything. reverse_sentence could simply be:

   string_reverse(my_sentence)
   reverse_words(my_sentence)
   return

@shrutivanw
Copy link

Looks good! I added some minor comments. I didn't see any explanation of the time and space complexities. Slack me if you'd like to soundboard your explanations or have any questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants