let's get IT with DAVINA ๐Ÿ’ป

[๋ฐฑ์ค€ #10808] ์•ŒํŒŒ๋ฒณ ๊ฐœ์ˆ˜ ๋ณธ๋ฌธ

DEV_IN/๋ฌธ์ œํ’€์ด

[๋ฐฑ์ค€ #10808] ์•ŒํŒŒ๋ฒณ ๊ฐœ์ˆ˜

๋‹ค๋นˆ์น˜์ฝ”๋“œ๐Ÿ’Ž 2023. 3. 13. 20:09

โ“ ๋ฌธ์ œ

์•ŒํŒŒ๋ฒณ ์†Œ๋ฌธ์ž๋กœ๋งŒ ์ด๋ฃจ์–ด์ง„ ๋‹จ์–ด S๊ฐ€ ์ฃผ์–ด์ง„๋‹ค. ๊ฐ ์•ŒํŒŒ๋ฒณ์ด ๋‹จ์–ด์— ๋ช‡ ๊ฐœ๊ฐ€ ํฌํ•จ๋˜์–ด ์žˆ๋Š”์ง€ ๊ตฌํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค.

์ž…๋ ฅ

์ฒซ์งธ ์ค„์— ๋‹จ์–ด S๊ฐ€ ์ฃผ์–ด์ง„๋‹ค. ๋‹จ์–ด์˜ ๊ธธ์ด๋Š” 100์„ ๋„˜์ง€ ์•Š์œผ๋ฉฐ, ์•ŒํŒŒ๋ฒณ ์†Œ๋ฌธ์ž๋กœ๋งŒ ์ด๋ฃจ์–ด์ ธ ์žˆ๋‹ค.

์ถœ๋ ฅ

๋‹จ์–ด์— ํฌํ•จ๋˜์–ด ์žˆ๋Š” a์˜ ๊ฐœ์ˆ˜, b์˜ ๊ฐœ์ˆ˜, …, z์˜ ๊ฐœ์ˆ˜๋ฅผ ๊ณต๋ฐฑ์œผ๋กœ ๊ตฌ๋ถ„ํ•ด์„œ ์ถœ๋ ฅํ•œ๋‹ค.

๐Ÿ—๏ธ ์˜ˆ์ œ ์ž…๋ ฅ

baekjoon

๐Ÿ—๏ธ ์˜ˆ์ œ ์ถœ๋ ฅ

1 1 0 0 1 0 0 0 0 1 1 0 0 1 2 0 0 0 0 0 0 0 0 0 0 0

โ—๏ธ ๋น„๋‹ˆ's ํ’€์ด

const fs = require("fs");
const input = fs.readFileSync("/dev/stdin").toString().trim();

let alphabet = "abcdefghijklmnopqrstuvwxyz";
let count = new Array(26).fill(0); //[0,0,0,....,0]

for (let i = 0; i < input.length; i++) {
    for (let j = 0; j < alphabet.length; j++) {
        if (input[i] === alphabet[j]) {
            count[j]++;
        }
    }
}

console.log(count.join(" "));//๋„์–ด์“ฐ๊ธฐ ์žˆ๋„๋ก ๋ฌธ์ž์—ด๋กœ ๋ฐ˜ํ™˜
Comments