FastPrepPalindrome After At Most One Deletion
Problems/Palindrome After At Most One Deletion

Palindrome After At Most One Deletion

Adobe logoAdobe● EasyFULLTIMEPHONE SCREEN
QuestionFunctionExamplesConstraints

Problem statement

Source note: This problem decides whether a lowercase string can read the same in both directions after removing at most one character. An Adobe CS 2 report names it, by link only, as the second of two first-round coding questions.

Our choices: lowercase letters only, 1 to 10000 characters, removing nothing is allowed, and new examples.

The judged task matches the report at about 90%.

A palindrome reads the same from left to right and from right to left, like "level".

Given a string s, you may delete at most one character from it (or none). Return true if the result can be a palindrome, and false otherwise.

Function

canBePalindrome(s: String) → boolean

Examples

Example 1

s = "racecxar"return = true

Delete the x to get "racecar", which reads the same both ways: true.

Example 2

s = "noon"return = true

The string already reads the same both ways, so no deletion is needed: true.

Example 3

s = "abcab"return = false

Deleting a single character never helps: the five results are "bcab", "acab", "abab", "abcb" and "abca", and none reads the same both ways: false.

Constraints

  • 1 <= s.length <= 10^4
  • s contains only lowercase English letters

More Adobe problems

  • Evaluate a Parenthesized Integer ExpressionPHONE SCREEN · Seen Oct 2026
  • All Elements of Two BSTs in OrderPHONE SCREEN · Seen Aug 2026
  • Rotate an Array In PlaceOA · PHONE SCREEN · Seen Aug 2026
All Adobe interview questionsSee Adobe hiring insights
Saved
public boolean canBePalindrome(String s) {
    // Write your code here.
}
Checking account…