Clean Python
Clean Python\n\nOfficial Solution N\xBA 4, with clean variables and a small check to prevent redundant work.\n\n\nclass Solution:\n    def reverse(self,A,i,j):\
**Clean Python**\n\nOfficial Solution N\xBA 4, with clean variables and a small check to prevent redundant work.\n\n```\nclass Solution:\n    def reverse(self,A,i,j):\n        while i<j:\n            A[i],A[j] = A[j],A[i]\n            i += 1\n            j -= 1\n    def rotate(self, A, k):\n        L  = len(A)\n        k %= L\n        if k:\n            self.reverse( A , 0 , L-1 )\n            self.reverse( A , 0 , k-1 )\n            self.reverse( A , k , L-1 )\n```
['Python', 'Python3']