Rearrange any selection of characters from s to form a string in which no run of equal characters is longer than repeatLimit. You may leave characters unused. Return the lexicographically largest valid string.
To compare two strings, compare their first differing characters: the later letter in the alphabet makes its string larger. If one string is a prefix of the other, the longer string is larger.
Example 1:
Input: s = "zzzza"
repeatLimit = 2
Output: "zzazz"Explanation: Start with "zz", then use a to separate that run from the remaining two z characters. The result "zzazz" uses all characters and never repeats a letter more than twice in a row.
Example 2:
Input: s = "bbbb"
repeatLimit = 2
Output: "bb"Explanation: Only b is available, so at most two characters can be used without exceeding the run limit. Return "bb" and leave the other two unused.
Example 3:
Input: s = "abcc"
repeatLimit = 1
Output: "cbca"Explanation: The largest first character is c. Then b separates it from the next c, and a can follow, producing "cbca" with no equal adjacent letters.
Constraints:
1 <= repeatLimit <= s.length <= 100000scontains only lowercase English letters.