对于一个给定的字符序列S,请你把其循环左移K位后的序列输出。例如,字符序列S=”abcXYZdef”,要求输出循环左移3位后的结果,即“XYZdefabc”。
# -*- coding:utf-8 -*-
class Solution:
def LeftRotateString(self, s, n):
# write code here
if s == "":
return ""
elif n <= len(s):
return s[n:]+s[:n]
else:
a = n%len(s)
return s[a:] + s[:a]