How would you like to learn today?
Visualize algorithms in real time, explore them step by step, or challenge yourself with a test.Choose a path to focus—or scroll down to preview all options.
Visualize the algorithm step-by-step with interactive animations in real time.
Read the full explanation, examples, and starter code at your own pace.
Drag and arrange the algorithm steps in the correct execution order.
🧠 Select Active to activate
Follow every state change, comparison, and transformation as the execution unfolds in real time.
📖 Select Passive to activate
MediumYou are given:
s consisting of lowercase English letters.repeatLimit.Your task is to construct a new string repeatLimitedString using the characters of s, such that no letter appears more than repeatLimit times consecutively.
The goal is to return the lexicographically largest string possible.
a is larger than string b if:
a has a character later in the alphabet.Input:
s = "cczazcc"
repeatLimit = 3
Output:
"bbabaa"
Steps:
s in descending order to maximize the lexicographical order:repeatLimit times consecutively.'z' → appears 2 times.'c' → appears 3 times.'a' → appears 1 time.'c' → 1 time (to avoid breaking the repeatLimit rule).'z' appears at most 2 times consecutively.'c' appears at most 3 times consecutively.'a' appears only 1 time.The string "zzcccac" satisfies all conditions and is lexicographically largest.
Input:
s = "aaabbccc" repeatLimit = 2
Output:
"ccbbaacc"
🎯 Select Challenge to activate
Drag and arrange the algorithm steps in the correct execution order instead of spending time typing code letter by letter.
The algorithm is divided into three logical parts. Carefully rearrange each section in the correct order to form a complete and valid solution.
Understand Below AlgorithmGreen text means the instruction is placed in the correct position.
Red text means the instruction is in the wrong position.
Instructions with the same background color indicate particular blocks start and end.
A tick mark means the instruction is correct and locked.
🔒 Locked steps cannot be moved. Only unlocked steps are draggable.
🔊 Enable sound for swap feedback and completion effects.