My solution in python

  • 0

    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.
    if k%len(nums) != 0:

            k = k%len(nums)
            nums[:len(nums)-k], nums[len(nums)-k:] = nums[len(nums)-k:],nums[:len(nums)-k]


Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.