题解 | #左旋转字符串#

左旋转字符串

https://www.nowcoder.com/practice/12d959b108cb42b1ab72cef4d36af5ec

#
# 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
#
#
# @param str string字符串
# @param n int整型
# @return string字符串
#
class Solution:
    def LeftRotateString(self, ss: str, n: int) -> str:
        # write code here
        if not ss or n == 0:
            return ss
        while n > 0:
            temp = ss[0]
            ss = ss[1:] + temp
            n -= 1
        return ss

全部评论

相关推荐

码农索隆:想看offer细节
点赞 评论 收藏
分享
不亏是提前批,神仙打架,鼠鼠不配了
站队站对牛:现在92都报工艺岗了
投递韶音科技等公司7个岗位
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务