左旋转字符串 Posted on 2019-08-13 | | reads times 左旋转字符串题目描述 对于一个给定的字符序列S,请你把其循环左移K位后的序列输出。例如,字符序列S=”abcXYZdef”,要求输出循环左移3位后的结果,即“XYZdefabc”。 123456789101112function LeftRotateString(str, n){ // write code here if(n==0)return str; let newstrbegin='',newstrend=''; if(str==null)return newstrbegin; newstrbegin=str.slice(n,str.length); newstrend=str.slice(0,n); return newstrbegin.concat(newstrend); } Post author: GoldMiner Xun Post link: https://goldminerxun.github.io/2019/08/13/%E5%89%91%E6%8C%87offer%20JavaScript%E7%89%88%20(43)/ Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 3.0 unless stating additionally.