1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-13 11:21:42 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee

add leetcode problem-cn part2

This commit is contained in:
2022-03-27 20:38:29 +08:00
parent 5a4fa6db12
commit 0fc7f4b734
1617 changed files with 134637 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
<p>In the classic problem of the Towers of Hanoi, you have 3 towers and N disks of different sizes which can slide onto any tower. The puzzle starts with disks sorted in ascending order of size from top to bottom (i.e., each disk sits on top of an even larger one). You have the following constraints:</p>
<p>(1) Only one disk can be moved at a time.<br />
(2) A disk is slid off the top of one tower onto another tower.<br />
(3) A disk cannot be placed on top of a smaller disk.</p>
<p>Write a program to move the disks from the first tower to the last using stacks.</p>
<p><strong>Example1:</strong></p>
<pre>
<strong> Input</strong>: A = [2, 1, 0], B = [], C = []
<strong> Output</strong>: C = [2, 1, 0]
</pre>
<p><strong>Example2:</strong></p>
<pre>
<strong> Input</strong>: A = [1, 0], B = [], C = []
<strong> Output</strong>: C = [1, 0]
</pre>
<p><strong>Note:</strong></p>
<ol>
<li><code>A.length &lt;= 14</code></li>
</ol>