Tap here to switch tabs
Problem
Submissions

Problem: Robot Printing the Lexicographically Smallest String

Try to solve the Robot Printing the Lexicographically Smallest String problem.

Statement

You are given a string s and a robot equipped with an empty string t and an empty output string p.

The robot can perform either of the following two operations in any order until both s and t become empty:

  1. Remove the first character from s and append it to the end of t.

  2. Remove the last character from t and append it to the end of p.

Return the lexicographically smallest string p that can be produced.

Constraints:

  • 1≤1 \leq s.length ≤105\leq 10^5

  • s consists of only English lowercase letters.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Robot Printing the Lexicographically Smallest String

Try to solve the Robot Printing the Lexicographically Smallest String problem.

Statement

You are given a string s and a robot equipped with an empty string t and an empty output string p.

The robot can perform either of the following two operations in any order until both s and t become empty:

  1. Remove the first character from s and append it to the end of t.

  2. Remove the last character from t and append it to the end of p.

Return the lexicographically smallest string p that can be produced.

Constraints:

  • 1≤1 \leq s.length ≤105\leq 10^5

  • s consists of only English lowercase letters.