#3223

Minimum Length of String After Operations

pupil · 500 · lc medium +27 · 75% accepted · 728 likes · top 86%

Description

You are given a string s. Repeat as desired:

- Pick index i where s[i] appears at least once to its left and once to its right.

- Delete the nearest copy to the left and the nearest copy to the right.

Return the minimum achievable length of s.

Code

1
2
3