LeetCode Problem #680
Given a non-empty string s
, you may delete at most one character. Judge whether you can make it a palindrome.
Example 1:
Input: "aba"
Output: True
Example 2:
Input: "abca"
Output: True
Explanation: You could delete the character 'c'.
Note:
- The string will only contain lowercase characters a-z. The maximum length of the string is 50000.
Solution
Things To Do Differently
- Index characters instead of removing from front and back of string.
- Check loop bounds.
- Think more carefully about single deleted character.
- Think about passing array by reference vs. a copy.
- Pros and cons of using same function name with different signature.
- When function returns bool, it's okay to return call to function.