My easy Python Solution, beat 94.47%


  • 0
    L

    '''

    def rotate(self, nums, k):
        if k and len(nums)>1:
            k = k % len(nums)
            nums[:len(nums)-k] = self.rev(nums[:len(nums)-k])
            nums[len(nums)-k:] = self.rev(nums[len(nums)-k:])
            nums = nums.reverse()
        else:
            pass
        
    def rev(self,n):
        n.reverse()
        return n
    

    '''


Log in to reply
 

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