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