8. 旋转字符串
给定一个字符串和一个偏移量,根据偏移量旋转字符串(从左向右旋转)
样例
对于字符串 "abcdefg"
.
offset=0 => "abcdefg"
offset=1 => "gabcdef"
offset=2 => "fgabcde"
offset=3 => "efgabcd"
class Solution: """ @param str: An array of char @param offset: An integer @return: nothing """ def rotateString(self, str, offset): # write your code hereif not offset: return if len(str) == 0 or offset == 0: return str for i in range(offset%len(str)): str.insert(0,str.pop())