#3703

Remove K-Balanced Substrings

expert · 1100 · lc medium +32 · 32.5% accepted · 128 likes · top 10%

Description

Given a parenthesis string s and an integer k, repeatedly remove every non-overlapping occurrence of exactly k consecutive '(' followed by k consecutive ')' until none remain, then return the resulting string.

Code

1
2
3