Tap here to switch tabs
Problem
Submissions

Problem: Minimum Length of String After Operations

med
30 min
Try to solve the Minimum Length of String After Operations problem.

Statement

You are given a string s.

You can perform the following operation on the string any number of times:

Choose an index i in s such that there is at least one identical character to the left of i and at least one identical character to the right of i.
Remove the closest identical character to the left of i.
Remove the closest identical character to the right of i.

Return the minimum possible length of s that can be achieved after performing any number of operations.

Constraints:

  • 1≤1 \leq s.length ≤2imes105\leq 2 imes 10^5

  • s consists only of lowercase English letters.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Length of String After Operations

med
30 min
Try to solve the Minimum Length of String After Operations problem.

Statement

You are given a string s.

You can perform the following operation on the string any number of times:

Choose an index i in s such that there is at least one identical character to the left of i and at least one identical character to the right of i.
Remove the closest identical character to the left of i.
Remove the closest identical character to the right of i.

Return the minimum possible length of s that can be achieved after performing any number of operations.

Constraints:

  • 1≤1 \leq s.length ≤2imes105\leq 2 imes 10^5

  • s consists only of lowercase English letters.