Given a 0-indexed string
s, repeatedly perform the following operation any number of times:
- Choose an index
iin the string, and letcbe the character in positioni. Delete the closest occurrence ofcto the left ofi(if any) and the closest occurrence ofcto the right ofi(if any).Your task is to minimize the length of
sby performing the above operation any number of times.Return an integer denoting the length of the minimized string.
1 | class Solution { |