Miss Me?
InterviewTime limit2sMemory limit1024 MB
Given a string, decide whether swapping exactly two characters (they may be equal) can turn it into a palindrome.
- Level
Medium4 of 10
- Topics
- String, Two pointers
- Solved
- No attempts yet
Problem
Miss me?
Jim Moriarty
Right now, every screen in London is broadcasting a video of Jim Moriarty addressing the city's residents. It is not yet known whether the supervillain survived, or whether someone else is using his notoriety for their own purposes. While the plane carrying Sherlock Holmes is landing, Watson and Lestrade have one urgent task: shut off the broadcast immediately so it does not traumatize the people of London.
They know that a password must be entered to turn off the broadcast. They know for certain that the password string must read the same from left to right as from right to left. Jim Moriarty sent them a text message with a string and the claim that the password can be obtained by swapping exactly two characters in it.
Now Watson and Lestrade want to check whether exactly two characters, which may be equal, can be swapped in this string so that it reads the same from left to right and from right to left.
Input
The only line of the input file contains a string (), the string Moriarty sent. consists only of lowercase letters of the English alphabet.
Output
Print Yes to the output file if a password can be obtained from the string, and No otherwise.