题解 | #左旋转字符串#

左旋转字符串

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

function LeftRotateString(str, n)
{
    // write code here
    if(n === 0) return str;
    if(!str) return "";
    for(let i = 0; i < n; i++){
        str = str.slice(1) + str[0]
    }
    return str;
}
module.exports = {
    LeftRotateString : LeftRotateString
};

全部评论

相关推荐

不吃牛肉的选手在刷面试经:首先,你数过吗?其次,他知道吗?最后,你说了他信吗?
点赞 评论 收藏
分享
牛客33727151号:不是哥们我以为驾照是段子呢
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务