class Solution:
"""
@param str: An array of char
@param offset: An integer
@return: nothing
"""
def rotateString(self, s, offset):
newstr=s[-offset:]+s[0:len(s)-offset]
return newstr
'''
有问题
'''
第一次改动,显示超时
class Solution:
"""
@param str: An array of char
@param offset: An integer
@return: nothing
"""
def rotateString(self, s, offset):
if not offset:
return
if not s:
return
for i in range(offset):
a=s.pop()
s.insert(0,a)
第二次改动
class Solution:
"""
@param str: An array of char
@param offset: An integer
@return: nothing
"""
def rotateString(self, s, offset):
if not offset:
return
if not s:
return
offset=offset%len(s)
for i in range(offset):
a=s.pop()
s.insert(0,a)