1165. Minimum Deletions to Make String Palindrome

EasyDynamic ProgrammingSequence DP

Given a string s, return the minimum number of characters to delete so that the remaining string is a palindrome. The input is JSON {s}.

Input: JSON {s}.

Output: Integer — the minimum deletions.

Examples

Example 1
Input: {"s":"aebcbda"}
Output: 2
Explanation: Delete 'e' and 'd'.
Example 2
Input: {"s":"abcba"}
Output: 0
Explanation: Already a palindrome.
Example 3
Input: {"s":"a"}
Output: 0
Explanation: Single character.

Constraints

Asked by

TCSInfosysWiproCognizantCapgemini
Solve this problem in the editor →