不允许使用另外的数组
class Solution:
def solve(self , n , m , a ):
# write code here
"""
不符合,不允许使用另外的数组
m = m % n
return a[(n-m)::] + a[0:(n-m)]
"""
m = m % n
def reverse(n, m, s):
while n < m:
s[n], s[m] = s[m], s[n]
n += 1
m -= 1
reverse(0, n-1, a)
reverse(0, m-1, a)
reverse(m, n-1, a)
return a