1. Valid palindrome
Algorithm:
- Initialize two pointers, left at the start and right at the end of the string.
- Iterate until the left pointer is before the right pointer, skipping non-alphanumeric characters for both pointers.
- Compare characters positioned at the left and right pointers in lowercase; if they differ, return FALSE.
- Move left forward and right backward to check the next pair of characters.
- If the traversal completes without mismatches, return TRUE indicating the string is a palindrome.
Python code:
Comments
Post a Comment