Medium
LABValid Palindrome IV
Return true if changing at most two characters can make s a palindrome.
EXAMPLES
Example 1
Input
{
"s": "abcdba"
}
Output
trueFUNCTION SHAPE
s: string→boolSOLUTION NOTE
Open on LeetCode ↗Note that this simple 2 pointers works because this is 'changes', and not removals. Removals will require DP because we have 2 options to remove, i or j. In this case of changes, we can choose either one to become the other, it doesn't matter which one we choose and it doesn't change our answer as each pair of indices is independent after matching.