rotatestring.py

'''
样例 1:

输入:  str="abcdefg", offset = 3
输出:  str = "efgabcd"
样例解释:  注意是原地旋转,即str旋转后为"efgabcd"
样例 2:

输入: str="abcdefg", offset = 0
输出: str = "abcdefg"
样例解释: 注意是原地旋转,即str旋转后为"abcdefg"
样例 3:

输入: str="abcdefg", offset = 1
输出: str = "gabcdef"
样例解释: 注意是原地旋转,即str旋转后为"gabcdef"
样例 4:

输入: str="abcdefg", offset =2
输出: str = "fgabcde"
样例解释: 注意是原地旋转,即str旋转后为"fgabcde"
样例 5:

输入: str="abcdefg", offset = 10
输出: str = "efgabcd"
样例解释: 注意是原地旋转,即str旋转后为"efgabcd"
'''


def rotateString( s, offset):
        # write your code here

    return s[len(s) - offset:] + s[:len(s) - offset]

if __name__ == '__main__':
    print(rotateString("abcdefg", 10))
上一篇:快速找到多个字典的公共键(key)


下一篇:08activiti - 开发环境准备