diff --git "a/junehee/[3\354\260\250] \354\225\225\354\266\225.js" "b/junehee/[3\354\260\250] \354\225\225\354\266\225.js" new file mode 100644 index 0000000..7a763e6 --- /dev/null +++ "b/junehee/[3\354\260\250] \354\225\225\354\266\225.js" @@ -0,0 +1,16 @@ +function solution(msg) { + const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".split(""); + const answer = []; + + for (let i = 0; i < msg.length; i++) { + for (let j = msg.length; j > i; j--) { + if (alphabet.includes(msg.slice(i, j))) { + alphabet.push(msg.slice(i, j + 1)); + answer.push(alphabet.indexOf(msg.slice(i, j)) + 1); + i += (j - i - 1); + } + } + } + + return answer; +}