Tap here to switch tabs
Problem
Submissions

Problem: Maximum Deletions on a String

med
30 min
Try to solve the Maximum Deletions on a String problem.

Statement

You are given a string s consisting of lowercase English letters.

In one operation, you can:

  1. Delete the first i letters of s (where 1≤1 \leq i ≤\leq s.length /2/ 2) if the first i letters are equal to the next i letters.

  2. Delete the entire string s.

Return the maximum number of operations required to completely delete s.

Constraints:

  • 1≤1 \leq s.length ≤4000\leq 4000

  • s consists only of lowercase English letters.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Deletions on a String

med
30 min
Try to solve the Maximum Deletions on a String problem.

Statement

You are given a string s consisting of lowercase English letters.

In one operation, you can:

  1. Delete the first i letters of s (where 1≤1 \leq i ≤\leq s.length /2/ 2) if the first i letters are equal to the next i letters.

  2. Delete the entire string s.

Return the maximum number of operations required to completely delete s.

Constraints:

  • 1≤1 \leq s.length ≤4000\leq 4000

  • s consists only of lowercase English letters.