1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-10-18 11:36:48 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
2022-03-29 12:43:11 +08:00
parent 58bbdfd57c
commit 2b0511d272
10721 changed files with 8123 additions and 8119 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>