What's the difference between that and :
for i in range(k): nums = [nums.pop()] + nums
I can't see the difference. But this is rejected and yours is accepted.
The length is not match. You have increased the length of nums.
Actually, I haven't.
Do this in REPL or in your IDE.
a = [1,2,3] a = [a.pop()] + a print(a)
a will show [3,1,2]
You are right.
Maybe your solution is rejected because it does't modify nums in-place.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.