Tower of Hanoi
Difficulty: Medium
Acceptance: %
Points: 30.00
In the Tower of Hanoi puzzle, you are given n disks arranged in ascending order (with the smallest disk on top) on the first of three rods. The objective is to move all the disks to the third rod while adhering to the following two rules: only one disk can be moved at a time, and no disk may be placed on top of a smaller disk. Given the number of disks n and the three rods labeled as "from" (the starting rod), "to" (the target rod), and "aux" (the auxiliary rod), the task is to calculate the total number of moves required to transfer all the disks from the starting rod to the target rod.
Expected Time Complexity: O(2^n)
Expected Auxiliary Space: O(n)