Easiest Python solution with assumption that k is in correct range:
def rotate(self, nums, k): return nums[-k:] + nums[:k]
It works on all my local test, but OJ gives me a return [1, 2] when input is [1, 2] and 1
I submitted, still the same. I really didn't figure out why it give me that. I tried to run on my only shell, it works fine
Thank you! I know, when I go to C++, its return value is void. So it's going to do it in place
Hi @BigTailWolf - I m sort of running into the same issue here. Works on my local , but the OJ rejects my solution :( and I m splicing the list as well . What did you figure out ?
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.