[Algorithm] 30 week(8.15 ~ 8.21) 1/3

Dev_min·2022년 8월 15일
0

algorithm

목록 보기
96/157

1309. Decrypt String from Alphabet to Integer Mapping

var freqAlphabets = function(s) {
    const alphabet = '_abcdefghijklmnopqrstuvwxyz';
    let result = '';

    for (let i = 0; i < s.length; i++) {
        if (s[i + 2] == '#') {
            result += alphabet[s[i] + s[i + 1]];
            i = i + 2;
        } else {
            result += alphabet[s[i]];
        }
    }
    return result;    
};
profile
TIL record

0개의 댓글