思路:
# -*- coding:utf-8 -*-
class Solution:
def LeftRotateString(self, s, n):
# write code here
return s[n:]+s[:n]
这个方法考虑的更加全面。
# -*- coding:utf-8 -*-
class Solution:
def LeftRotateString(self, s, n):
# write code here
length=len(s)
if length==0:
return ""
else:
n=n%length
s=s+s
return s[n:n+length]