Tap here to switch tabs
Problem
Submissions

Problem: Increasing Decreasing String

Try to solve the Increasing Decreasing String problem.

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

Try to solve the Increasing Decreasing String problem.

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.