class Solution(object): def rotate(self, nums, k): """ :type nums: List[int] :type k: int :rtype: void Do not return anything, modify nums in-place instead. """ nums = nums[-k:] + nums[:-k] x = Solution() x.rotate([1,2], 1)
Local output: [2, 1]
[Finished in 0.054s]
Online judge: Output:
I'm having the same problem! It gives me the wrong answer for that test case. Code works on local machine
This is my code -
def rotate(self, nums, k): k=k%len(nums) nums=nums[k:]+nums[:k]
Did you get it resolved by any chance?
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.