Practice
Two-Pointer Palindrome Word
2025/May/June·Variant 2·Q6·[6 marks]
MEDIUMString Processing
Read one uppercase word. Use two indexes: one at the first character and one at the last. Walk them towards the middle. If every pair matches, output Palindrome; as soon as a pair differs, output Not palindrome.
Input: One word.
Output: Palindrome or Not palindrome.
Example:
Input: RACECAR
Output: Palindrome
Sample Test Cases
Test 1: Odd-length palindrome
Inputs: RACECAR
Expected: Palindrome
Test 2: Mismatch on the second pair
Inputs: TREAT
Expected: Not palindrome