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) - Palindrome Check #29

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

Conversation

haydenwalls
Copy link

time complexity: O(n) because it must iterate through each element in the array
space complexity: O(1) because it does not require any additional memory space besides the iteration variables

j = my_phrase.length - 1
while i < j
if my_phrase[i] == " " || my_phrase[j] == " "
until my_phrase[i] != " "

Choose a reason for hiding this comment

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

In the two nested inner loops, continue to check and confirm that i is less than j before comparing the character at the index i (or j) with a white space.

end


# time complexity: O(n) because it must iterate through each element in the array

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. In this case, it would be the number of characters in the input string or the size of the input string.

@shrutivanw
Copy link

Nice work!

Please see some minor comments to make your algorithm further robust.

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