Practice Construct String With Repeat Limit
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Construct String With Repeat Limit
Problem Statement
You are given a string s and an integer repeatLimit. Construct a new string repeatLimitedString using the characters of s such that no letter appears more than repeatLimit times in a row. You do not have to use all characters from s. Return the lexicographically largest repeatLimitedString possible. A string a is lexicographically larger than a string b if in the first position where a and b differ, string a has a letter that appears later in the alphabet than the corresponding letter in b. If the first min(a.length, b.length) characters do not differ, then the longer string is the lexicographically larger one.
Source: Construct String With Repeat Limit on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
s = "cczazcc", repeatLimit = 3
"zzcccac"
# Example 2
s = "aababab", repeatLimit = 2
"bbabaa"
Constraints
Related LeetCode Problems
Practice more problems similar to Construct String With Repeat Limit.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.