[leetcode, JS] 3210. Find the Encrypted String

mxxn·2024년 8월 2일
0

leetcode

목록 보기
198/198

문제

문제 링크 : Find the Encrypted String

풀이

/**
 * @param {string} s
 * @param {number} k
 * @return {string}
 */
var getEncryptedString = function(s, k) {
    let result = ''
    
    for(let i=0; i<s.length; i++) {
        result += s[(i+k) % s.length]
    }

    return result
};
  1. result에 s[(i+k) % s.length]를 더하는 방식
  • Runtime 59 ms, Memory 51.77 MB
profile
내일도 글쓰기

0개의 댓글