3703. Remove K-Balanced Substrings
You are given a string
sconsisting of'('and')', and an integerk.A string is k-balanced if it is exactly
kconsecutive'('followed bykconsecutive')', i.e.,'(' * k + ')' * k.For example, if
k = 3, k-balanced is"((()))".You must repeatedly remove all non-overlapping k-balanced substrings from
s, and then join the remaining parts. Continue this process until no k-balanced substring exists.Return the final string after all possible removals.
1 | class Solution { |