DevHireLab
TutorialsBootcamp
Problems
Code SimulatorAI InterviewSoonContact
DevHireLab
TutorialsBootcamp
Problems
Code SimulatorAI InterviewSoonContact
Back to Arena
easy
String

Is Palindrome II (allow one deletion)

**Problem Statement:** Given the required input arguments, write an efficient algorithm to solve the **Is Palindrome II (allow one deletion)** problem. Implement the required logic as specified by standard definitions for this classic algorithmic challenge. **Hint / Expected Approach:** Two-pointer; on mismatch try skip left or skip right **Edge Cases to Consider:** - (1) Already palindrome - (2) Two mismatches (false) - (3) Odd length single char in middle

Examples

Example 1
Input: "aba"
Output: true
Explanation: Already palindrome
Example 2
Input: "abca"
Output: true
Explanation: Delete 'c'
Example 3
Input: "abc"
Output: false
Explanation: Two changes needed

Constraints

  • ▪1 <= s.length <= 10^4
  • ▪s consists of printable ASCII characters
  • ▪Solve with optimal space complexity

Watch Out For Edge Cases

  • ▪Already palindrome
  • ▪Two mismatches (false)
  • ▪Odd length single char in middle
Frequently Asked At
AmazonMetaMicrosoftFlipkart