Appearance
示例 1: 输入: s = "abcdefg", k = 2 输出: "cdefgab" 示例 2: 输入: s = "lrloseumgh", k = 6 输出: "umghlrlose"
解法1:直接使用剪切字符串API
/** * @param {string} s * @param {number} n * @return {string} */ const reverseLeftWords = function (s, n) { return s.slice(n) + s.slice(0, n) }
题链