lintcode:8. 旋转字符串
2019-01-24 20:58
281 查看
lintcode:8. 旋转字符串
给定一个字符串和一个偏移量,根据偏移量旋转字符串(从左向右旋转) https://www.lintcode.com/problem/rotate-string/description
解题思路:每一次偏移实际上是取出最后一个字母,然后插在首位。
class Solution: """ @param str: An array of char @param offset: An integer @return: nothing """ def rotateString(self, str, offset): # write your code here if not str: return if offset > len(str): offset = offset % len(str) for i in range(offset): char = str.pop() str.insert(0,char) return
相关文章推荐
- lintcode--旋转字符串
- lintcode 旋转字符串
- [LintCode]8.旋转字符串
- 8. 旋转字符串 —— LintCode
- LintCode 8.旋转字符串
- LintCode(easy)旋转字符串(!!!我有史以来解决的问题最快的一次,心酸流泪)
- LintCode 旋转字符串
- LintCode 面试题 旋转字符串
- (lintcode)第8题旋转字符串
- lintcode:旋转字符串
- LintCode 8.旋转字符串 C++
- 【LintCode】旋转字符串 - [Microsoft Onsite III] - Easy
- Lintcode 旋转字符串
- LintCode【简单】8. 旋转字符串 。代码及思路
- Lintcode 008 :旋转字符串
- 【LintCode】Rotate String 旋转字符串
- 字符串的左旋转
- 面试题42:旋转字符串
- LintCode:旋转图像
- 算法导论 32.4-5 字符串的循环旋转问题