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

palindrome finished #33

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

Conversation

leannerivera
Copy link

No description provided.

# puts palindrome_check("han nah ")

while i < j do
if my_phrase[i] == my_phrase[j]

Choose a reason for hiding this comment

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

I'd recommend taking care of preceding and trailing white spaces before comparing the two characters. That way when you do compare the character at index i with the character at index j, you can be sure that they are not equal.

if my_phrase[i] == my_phrase[j]
i += 1

until my_phrase[i] != " " do

Choose a reason for hiding this comment

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

Also continue to check that i < j before comparing the character at index i with a white space.


j -= 1

until my_phrase[j] != " " do

Choose a reason for hiding this comment

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

Also continue to check that i < j before comparing the character at index j with a white space.

@shrutivanw
Copy link

Your algorithm is getting close to a fully working solution. I added some comments inline.

With regards to time and space complexities, I did not see any comments on it. Take some time deduce and explain the time and space complexities for your algorithm. 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.

Slack me if you'd like to discuss further.

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