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

Hayden - Edges - C10 " reverse words " coding challenge #36

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

Conversation

haydenwalls
Copy link

The time complexity of this algorithm is O(n), because it has to iterate through each character of the string. The space complexity is constant because the characters of the string are reversed in place.

j -= 1
end

i = max + 1

Choose a reason for hiding this comment

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

Your algorithm does work currently for the test cases in place. At the end of the loop ending on line 29 however, i and j have the same values. Then, you update i to be max+1 on line 31. Which means in the most typical scenarios, j will be less than i after line 31. For efficiency, it might be worthwhile to make j also the same value.

@shrutivanw
Copy link

Nice work! 👍

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