so, n=7 ,k = 2

reverse(S,1,2) we get [2,1,3,4,5,6,7]

reverse(S,3,7) we get [2,1,7,6,5,4,3]

reverse(S,1,7) we get [3,4,5,6,7,1,2]

It is explaind in the above lines,

see, reverse(S,1,2) - reverse elements form index 1 to 2 of list S = **[1, 2**, 3, 4, 5, 6, 7]..

we get S = [**2,1,**3,4,5,6,7].

Now reverse(S,3,7) - reverse elements from index 3 to 7 of lis S = [2,1**,3,4,5,6,7**].

we get S = [2,1,**7,6,5,4,3**].

Now reverse(S,1,7) - reverse elements from index 1 to 7 of lis S =[**2,1,7,6,5,4,3**].

we get S = [ 3,4,5,6,7,1,2 ]

now compare this final list([ 3,4,5,6,7,1,2 ]) with the initial list ( [1,2,3,4,5,6,7]), you will see the rotation of elements towards left.

example- initially 3 was at index 3 and now it is at index 1.

initially 1 was at indext 1 and now it is at index 6. { don't confuse with its a right rotation with k= 5}.

similaly you can verify other elements shift.