The Tower of Hanoi is a famous coding interview question.
So let's go ahead and take a look at this question.
So over here we have the question.
Let's read it together.
We have three roads and n disks.
The objective of the puzzle is to move the entire stack to another rod.
Initially, these disks are in the rod one.
You need to print all the steps of disk movement so that all the disks reach the third rod.
Also find and return the total moves.
Note the disks are arranged such that the top disk is numbered one, and the bottom most disk is numbered
n.
Also, all the disks have different sizes, and a bigger disk cannot be put on the top of a smaller
disk.
You can only move one disk at a time.
So this is the question at hand.
Let's now first try to understand what is asked in the problem statement.
So over here it's mentioned that we are given three rods.
Okay.
So we are given three rods.
Let's draw the three rods over here.
So this is rod one.
This is rod two and this is rod three.
And let's say for understanding this question let's assume that rod one has three disks.
So these are three disks on rod one.
Notice that the size of the disks are different.
And it's also given that you cannot place a bigger disk on top of a smaller disk.
So the note is the arrangement over here.
And the question is we need to move all these disks over here from this rod over here to the final rod
okay.
So we need to move the entire stack to another rod.
So this is the puzzle.
But the condition is that we can only move one disk at a time.
So that's mentioned over here.
And a moment like this where you have a bigger disk on top of a smaller disk is wrong.
So this is the question over here.
And we can call these rods as the from rod the two rod.
And this could be called the auxiliary rod or the helper rod.
Now what is the expected output as per the question.
There are two things that we need to take care.
One is that we need to print.
That's mentioned over here all the steps of disk movement.
So we need to print all the steps of disk movement.
And we also need to return the total number of moves.
For example, if the question is that we have to move three disks from the from rod to the two rod,
then the output that is expected is something like this.
So for example, the first print statement over here says move disk one.
So let's say this is disk one.
This is disk two.
This is disk three.
So move disk one from rod one to rod three.
So we have to move this guy from rod one to rod three.
And then move disk two from rod one to row two.
And it goes on like that okay.
So we will see how we come up with this.
But again over here we are just trying to understand the question.
So we need to move all these disks from the from rod to the two rod without violating the given conditions,
which is that we can only move one disk at a time, and we can never place a larger disk on top of a
smaller disk.
So this is a violation.
Okay.
So this is a violation.
So this is the question at hand.
And we need to print all the movements.
And finally notice that we have seven print statements over here or seven movements of disks.
And that's why we need to return the value seven as well.
So we have understood the question in the next video, let's try to think about how we can solve this
and what method would be an appropriate method for solving this question.