@@ -0,0 +1,1554 @@
+class Solution:%0A    # @param %7Binteger%5B%5D%7D nums%0A    # @param %7Binteger%7D k%0A    # @return %7Bvoid%7D Do not return anything, modify nums in-place instead.%0A    def rotate(self, nums, k):%0A        if len(nums) in %5B0, 1%5D:%0A            return%0A        k = k %25 len(nums)%0A        if k == 0:%0A            return%0A        nums = self.reverse(nums, 0, len(nums) - 1)%0A        nums = self.reverse(nums, 0, k - 1)%0A        nums = self.reverse(nums, k, len(nums) - 1)%0A%0A    %0A    def reverse(self, nums, begin, end):%0A        while begin %3C end:%0A            nums%5Bbegin%5D, nums%5Bend%5D = nums%5Bend%5D, nums%5Bbegin%5D%0A            begin += 1%0A            end -= 1%0A        return nums%0A%0A        %0A    def arotate(self, nums, k):%0A        if len(nums) in %5B0, 1%5D:%0A            return%0A        k = k %25 len(nums)%0A        if k == 0:%0A            return%0A        if len(nums) - k %3C k:%0A            return self.rotateLeft(nums, len(nums) - k)%0A        return self.rotateRight(nums, k)%0A            %0A    %0A    def rotateLeft(self, nums, k):%0A        for i in range(k):%0A            tmp = nums%5B0%5D%0A            for j in range(len(nums)-1):%0A                nums%5Bj%5D = nums%5Bj+1%5D%0A            nums%5B-1%5D = tmp%0A        return nums%0A%0A        %0A    def rotateRight(self, nums, k):%0A        for i in range(k):%0A            tmp = nums%5B-1%5D%0A            for j in range(len(nums)-2, -1, -1):%0A                nums%5Bj+1%5D = nums%5Bj%5D%0A            nums%5B0%5D = tmp%0A        return nums%0A        %0A %0Aif __name__ == %22__main__%22:%0A    sol = Solution()%0A    print sol.reverse(%5B1,2,3,4,5,6%5D, 3, 5)%0A    print sol.rotate(%5B1,2,3,4,5,6%5D, 1)%0A    print sol.rotate(%5B1%5D, 0)%0A%0A

solve 189