Tap here to switch tabs
Problem
Submissions

Problem: Increasing Decreasing String

In Increasing Decreasing String, reorder the string by repeatedly choosing the smallest unused letter, then larger letters, followed by the largest unused letter and smaller ones; return the result.

Statement

Given a string s, reorder its characters using the following algorithm:

11. Choose the smallest character from s and append it to the result.
22. Choose the smallest character from s that is strictly greater than the last appended character, and append it to the result.
33. Repeat step 22 until no further characters can be picked.
44. Choose the largest character from s and append it to the result.
55. Choose the largest character from s that is strictly smaller than the last appended character, and append it to the result.
66. Repeat step 55 until no further characters can be picked.
77. Repeat steps 11 to 66 until all characters from s have been used.

Return the resulting string.

Constraints:

  • 1≤1 \leq s.length ≤500\leq 500

  • s consists of only lowercase English letters.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Increasing Decreasing String

In Increasing Decreasing String, reorder the string by repeatedly choosing the smallest unused letter, then larger letters, followed by the largest unused letter and smaller ones; return the result.

Statement

Given a string s, reorder its characters using the following algorithm:

11. Choose the smallest character from s and append it to the result.
22. Choose the smallest character from s that is strictly greater than the last appended character, and append it to the result.
33. Repeat step 22 until no further characters can be picked.
44. Choose the largest character from s and append it to the result.
55. Choose the largest character from s that is strictly smaller than the last appended character, and append it to the result.
66. Repeat step 55 until no further characters can be picked.
77. Repeat steps 11 to 66 until all characters from s have been used.

Return the resulting string.

Constraints:

  • 1≤1 \leq s.length ≤500\leq 500

  • s consists of only lowercase English letters.