Sir can the value of k be greater than n?

If yes then what shall be the output, should the list be same or should it be totally reversed?

yes it can be

if(k==n) do nothing just return;

if(k>n) k=k%n;

suppose n=5 and k=7
means append last 7 element which means append only 2 element
because after append first 5 element list look exactly same

i hope this helps
if yes hit a like and don’t forgot to mark doubt as resolved
if you have more doubts regarding this feel free to ask