You are given a string
sconsisting of lowercase English letters and an integerk.Two equal characters in the current string
sare considered close if the distance between their indices is at mostk.When two characters are close, the right one merges into the left. Merges happen one at a time, and after each merge, the string updates until no more merges are possible.
Return the resulting string after performing all possible merges.
Note: If multiple merges are possible, always merge the pair with the smallest left index. If multiple pairs share the smallest left index, choose the pair with the smallest right index.
1 | class Solution { |