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

Jane's palindrome_check #32

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

Conversation

JaneEdwMcN
Copy link

No description provided.

@@ -1,5 +1,45 @@
# A method to check if the input string is a palindrome.
# Return true if the string is a palindrome. Return false otherwise.
# Time Complexity: O(n)

Choose a reason for hiding this comment

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

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. In this case, n is the number of characters in the input string parameter.

@shrutivanw
Copy link

Good job on the algorithm. Try to practice explaining your time and space complexities further.

Can you think of an approach that improves the space complexity without negatively impacting the time complexity? Think of how can you avoid creating duplicate strings (original and reversed) and instead just examine the white spaces instead?
After giving it some thought, you may look at one such solution here: 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