题解 | #字符串的排列#

左旋转字符串

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

切片轻松搞定

function LeftRotateString(str, n)
{
    // write code here
    if(!str) return "";
    n = n % str.length;
    let res = str.slice(n,str.length) + str.slice(0,n);
    return res;
}
module.exports = {
    LeftRotateString : LeftRotateString
};
全部评论

相关推荐

05-29 09:02
门头沟学院 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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