Hi everyone, let's do this question.
Given an array, rotate the array to the right by k steps where k is non-negative.
So that's the question.
Now over here we have an example.
Let's say the array which is given to us is 1234 over here.
And if k is equal to one then we have to do one rotation to the right right.
So that will give us 4123.
So you can see that this four over here actually came was rotated to the right.
And because there's nothing over here it came over here.
Right.
So we have 4123.
Now if you do one more rotation that is if k is equal to two then we have after one rotation we have
4123.
And then this three comes over here right.
So this comes over here and we get 341 and two.
So that is what we call right rotations.
So this is the question which we have over here.
Now remember in the interview when you get this question always feel free to ask clarifying questions
so that you thoroughly understand the question and you and the interviewer are on the same page.
So for example, a sample question that you could ask over here is what happens if an empty array is
passed.
So in this case let's say the interviewer replies return an empty array in this case.
All right.
Now another question is if k is equal to zero no rotation is to happen.
Is that correct.
And then let's say the interviewer replies yes.
So you have got a good understanding of the question.
Now let's go ahead and write a few test cases.
Now remember in the interview you can always ask the interviewer, is it okay if we come up with a few
test cases together.
So this will ensure that you are on the same page with the interviewer.
Now let's go ahead and make a few test cases over here.
If the given array is one comma two, and if k is equal to one, then we're just doing one rotation
right.
So this two comes over here and we get two comma one as the output.
Now in this case if k is equal to two we do one more rotation and we get back to one comma two.
All right.
Now let's say the given array is 1234 and k is equal to three.
Right.
So in this case what will happen after one rotation.
We will have 412 and three.
After the next rotation we will have 341 and two.
And after the third rotation we will have 234 and one.
So this would be the case.
Now in this same case if k is equal to zero then we wouldn't do any rotation.
And the array is still one, two, three and four.
So that's clear.
And if an empty array is given and let's say k is equal to two, we just return the empty array.
So we have got a good understanding of the question.
And we have written our test cases in the next video.
Let's think through how we can solve this.
And let's also look at the complexity of analysis of the solutions that we come up with.