Tap here to switch tabs
Problem
Submissions

Problem: Minimize String Length

med
30 min
Try to solve the Minimize String Length problem.

Statement

Given a string s, you can perform the following operation any number of times:

11. Select an index i in s, and let c be the character at s[i].
22. Remove the closest occurrence of c to the left of i, if one exists.
33. Remove the closest occurrence of c to the right of i, if one exists.

Return the minimum possible length of s after performing any number of operations.

Constraints:

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

  • s contains only lowercase English letters

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimize String Length

med
30 min
Try to solve the Minimize String Length problem.

Statement

Given a string s, you can perform the following operation any number of times:

11. Select an index i in s, and let c be the character at s[i].
22. Remove the closest occurrence of c to the left of i, if one exists.
33. Remove the closest occurrence of c to the right of i, if one exists.

Return the minimum possible length of s after performing any number of operations.

Constraints:

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

  • s contains only lowercase English letters