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

sam jo's palindrome check (nodes) #24

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

Conversation

sjlee3157
Copy link

No description provided.

return false
end

stripped_phrase = ""

Choose a reason for hiding this comment

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

Creating a new string, i.e. stripped_phrase will increase the time complexity. Can you think of an algorithm that does not need this additional copy of the string and can skip white spaces as it examines them?

@@ -1,5 +1,31 @@
# A method to check if the input string is a palindrome.
# Return true if the string is a palindrome. Return false otherwise.
def palindrome_check(my_phrase)

Choose a reason for hiding this comment

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

I didn't see any comments on the time and space complexity of your algorithm. Can you think through it and explain it?
Gentle reminder: Always explain what n stands for while explaining your time and space complexity. That along with your explanation for reasoning behind your answer, is the complete answer for the time and space complexity.

@shrutivanw
Copy link

Nice job working on the algorithm. See comments inline for further thinking and for explaining the time and space complexity of your algorithm.

Also take a look at an alternative algorithm on: https://github.com/Ada-C10/palindrome_check/blob/solution/lib/palindrome_check.rb

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