[leetcode, JS] 2194. Cells in a Range on an Excel Sheet

mxxn·2023년 12월 18일
0

leetcode

목록 보기
150/198

문제

문제 링크 : Cells in a Range on an Excel Sheet

풀이

/**
 * @param {string} s
 * @return {string[]}
 */
var cellsInRange = function(s) {
    const result = []
    const startIdx = s[0].charCodeAt()
    const endIdx = s[3].charCodeAt()
    const startRow = +s[1]
    const endRow = +s[4]

    for(let i=startIdx; i<=endIdx; i++){
        for(let j=startRow; j<=endRow; j++) {
            result.push(String.fromCharCode(i)+j)
        }
    }

    return result
};
  1. 이중 for문을 만들어서 풀이
  • Runtime 54 ms, Memory 45.00 MB
profile
내일도 글쓰기

0개의 댓글