2dbi
Home/Akamai/Check if a String Is a Palindrome (and Variants)
AAkamai·DSASWE-2Technical Phone Screen

Check if a String Is a Palindrome (and Variants)

Problem

Check whether a string is a palindrome, then the 'valid palindrome after removing at most one char' variant.

Example

"aba" -> true; "abca" -> true (remove c)

Constraints

  • 1 ≤ |s| ≤ 10^5

Approach

Two pointers; on mismatch try skipping either side. Reported Akamai question.

added 6 days ago
LeadersAccount