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

Lisa's recursion exercise #1

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

Conversation

Lisa-Sano
Copy link

Lisa Rolczynski

return true if end_index - start_index <= 1

if s_array[start_index] == s_array[end_index]
return true && pal_helper(s_array, start_index+1, end_index-1)

Choose a reason for hiding this comment

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

there's no reason for the "true &" here. Because you are essentially just returning the result of the recursive call anyway -- this is called 'tail recursion' when a return value is passed all the way up the stack.

@sudocrystal
Copy link

👍 nice job!

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