Practice Increasing Decreasing String
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Build a result by repeatedly taking characters from s. On an ascending pass, append the smallest remaining character, then the smallest remaining character strictly greater than the last one appended, continuing until none qualifies. On a descending pass, append the largest remaining character, then the largest remaining character strictly smaller than the last one appended, continuing until none qualifies. Alternate these passes until no characters remain. Remove each selected occurrence from s; identical occurrences are interchangeable. Return the result.
Source: Increasing Decreasing String on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
s = "aaaabbbbcccc"
"abccbaabccba"
# Example 2
s = "rat"
"art"
Constraints
Related LeetCode Problems
Practice more problems similar to Increasing Decreasing String.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.