개발자 첫걸음/백준
백준 [BOJ 10809] - 알파벳 찾기
프로아마추어
2022. 10. 3. 16:13
나의 풀이
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
const str = require("fs")
.readFileSync(0)
.toString()
.trim()
.split("");
const alphabet = new Array(26);
alphabet.fill(-1);
str.forEach((s, idx) => {
if (alphabet[s.charCodeAt() - 97] === -1) {
alphabet[s.charCodeAt() - 97] = idx;
}
});
console.log(alphabet.join(" "));
|
cs |