Dsa
Two Pointers
Medium
Maximize Palindrome Length
Given a string s, you can modify at most one character to form the longest palindrome possible. Return the length of this palindrome. If the string is already a palindrome, return its length.
Input:
A single line containing the string s (1 <= |s| <= 1000).
Output:
An integer representing the length of the longest possible palindrome.
Example:
Input:
saturday
Output:
9
Explanation: We can change 'd' to 'u' to form 'saturuus'.
Key concepts
two_pointersstringpalindrome
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now