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

Naheed Edges reverse_sentence #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

arangn
Copy link

@arangn arangn commented Sep 29, 2018

No description provided.

if my_sentence == nil || my_sentence.length == 1 || my_sentence.length == 0
return my_sentence
end
my_sentence = reverse_words(my_sentence)

Choose a reason for hiding this comment

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

Since reverse_words is doing all the string manipulations in-place and so is string_reverse, you don't need to return anything from those methods or assign them in this method.

Lines 8 and 9 can simply be:

   reverse_words(my_sentence)
   string_reverse(my_sentence, 0, (my_sentence.length - 1))

# binding.pry
my_sentence = string_reverse(my_sentence, 0, (my_sentence.length - 1))
# binding.pry
return my_sentence

Choose a reason for hiding this comment

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

Since all the string manipulations are being done in-place, lines 6 and 12 can simply be return

@shrutivanw
Copy link

Nice work!

I added some minor comments inline.

I didn't see explanations on the time and space complexities. Take a read on https://github.com/Ada-C10/reverse_sentence/blob/solution/lib/reverse_sentence.rb and let me know if you 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