01.10 · Problem
Tower of Hanoi
There are three pegs: 1, 2 and 3. Peg 1 holds n disks, biggest at the bottom. Move them all to peg 3:
- Move one disk at a time.
- Never put a bigger disk on a smaller one.
Return the moves in order, each as [from, to], using the fewest moves.
Examples
Example 1
Input: n = 1
Output: [[1, 3]]solulu Pro
Continue this problem with Pro
Inside: step-by-step hints · 8 hidden tests · reference solutions · code editor.
Lifetime ₹1,999 ₹999 · Launch offer
Item 10 of 44 · updated 2026-10-13