cswork / libraryOpen practice workspace

Coding questions · Bloomberg

Check near-palindrome with one deletion

This question evaluates string manipulation and algorithmic problem-solving skills, focusing on palindromic properties and robust handling of edge cases within the Coding & Algorithms domain.

Given a string s, determine if it can become a palindrome after deleting at most one character. Return true or false and provide time and space complexity. Follow up: output one valid index to delete if possible.

Valid Near-Palindrome with One Deletion

Examples

Example 1

Input: ('aba',)
Output: True

Explanation: Already palindrome.

Example 2

Input: ('abca',)
Output: True

Explanation: Delete b or c.

Hints

  1. Choose a representation that makes the core operation simple.
  2. Handle empty and boundary inputs before the main algorithm.