Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c26f1dc

Browse files
Create README - LeetHub
1 parent 49c5ecb commit c26f1dc

File tree

1 file changed

+51
-0
lines changed
  • 2434-using-a-robot-to-print-the-lexicographically-smallest-string

1 file changed

+51
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<h2><a href="https://leetcode.com/problems/using-a-robot-to-print-the-lexicographically-smallest-string/?envType=daily-question&envId=2025年06月06日">2434. Using a Robot to Print the Lexicographically Smallest String</a></h2><h3>Medium</h3><hr><p>You are given a string <code>s</code> and a robot that currently holds an empty string <code>t</code>. Apply one of the following operations until <code>s</code> and <code>t</code> <strong>are both empty</strong>:</p>
2+
3+
<ul>
4+
<li>Remove the <strong>first</strong> character of a string <code>s</code> and give it to the robot. The robot will append this character to the string <code>t</code>.</li>
5+
<li>Remove the <strong>last</strong> character of a string <code>t</code> and give it to the robot. The robot will write this character on paper.</li>
6+
</ul>
7+
8+
<p>Return <em>the lexicographically smallest string that can be written on the paper.</em></p>
9+
10+
<p>&nbsp;</p>
11+
<p><strong class="example">Example 1:</strong></p>
12+
13+
<pre>
14+
<strong>Input:</strong> s = &quot;zza&quot;
15+
<strong>Output:</strong> &quot;azz&quot;
16+
<strong>Explanation:</strong> Let p denote the written string.
17+
Initially p=&quot;&quot;, s=&quot;zza&quot;, t=&quot;&quot;.
18+
Perform first operation three times p=&quot;&quot;, s=&quot;&quot;, t=&quot;zza&quot;.
19+
Perform second operation three times p=&quot;azz&quot;, s=&quot;&quot;, t=&quot;&quot;.
20+
</pre>
21+
22+
<p><strong class="example">Example 2:</strong></p>
23+
24+
<pre>
25+
<strong>Input:</strong> s = &quot;bac&quot;
26+
<strong>Output:</strong> &quot;abc&quot;
27+
<strong>Explanation:</strong> Let p denote the written string.
28+
Perform first operation twice p=&quot;&quot;, s=&quot;c&quot;, t=&quot;ba&quot;.
29+
Perform second operation twice p=&quot;ab&quot;, s=&quot;c&quot;, t=&quot;&quot;.
30+
Perform first operation p=&quot;ab&quot;, s=&quot;&quot;, t=&quot;c&quot;.
31+
Perform second operation p=&quot;abc&quot;, s=&quot;&quot;, t=&quot;&quot;.
32+
</pre>
33+
34+
<p><strong class="example">Example 3:</strong></p>
35+
36+
<pre>
37+
<strong>Input:</strong> s = &quot;bdda&quot;
38+
<strong>Output:</strong> &quot;addb&quot;
39+
<strong>Explanation:</strong> Let p denote the written string.
40+
Initially p=&quot;&quot;, s=&quot;bdda&quot;, t=&quot;&quot;.
41+
Perform first operation four times p=&quot;&quot;, s=&quot;&quot;, t=&quot;bdda&quot;.
42+
Perform second operation four times p=&quot;addb&quot;, s=&quot;&quot;, t=&quot;&quot;.
43+
</pre>
44+
45+
<p>&nbsp;</p>
46+
<p><strong>Constraints:</strong></p>
47+
48+
<ul>
49+
<li><code>1 &lt;= s.length &lt;= 10<sup>5</sup></code></li>
50+
<li><code>s</code> consists of only English lowercase letters.</li>
51+
</ul>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /