I thought this problem lack of testcases which satisfied k > 2*nums.length.
I wrote an Accepted program:
1.when k<nums.length:
(1)reverse the whole Array nums[]; [1,2,3,4,5,6,7]->[7,6,5,4,3,2,1]
(2)reverse the SubArrar(index from 0 to k-1)and the rest SubArray(index from k to nums.length-1); [7,6,5,4,3,2,1]->[5,6,7, 1,2,3,4]
2.if(k>nums.length),rotate k equals to rotate k-nums.length.
the right sttp should be: " if(k>nums.length)k=k%nums.length;"
Then jump to the step 1;
But this one: " if(k>nums.length)k=k-nums.length;" also Accepted!
So I don't think there have testcases whichs satisfied k>2*nums.length;(for example [1,2,3]k=7)