https://www.acmicpc.net/problem/2941
const fs = require('fs');
let croatia = fs.readFileSync('/dev/stdin').toString().trim();
const croatiaList = ['c=', 'c-', 'dz=', 'd-', 'lj', 'nj', 's=', 'z='];
const result = [];
let cnt = 0;
let flag = true;
while(flag){
let include = false;
for(let i = 0 ; i < croatiaList.length ; i++) {
if(croatia.includes(croatiaList[i])) {
include = true;
croatia = croatia.replace(croatiaList[i], ' ');
result.push(croatiaList[i]);
break;
}
}
if(!include) flag = false;
}
croatia = croatia.replaceAll(' ', '').split("");
console.log(result.length+croatia.length);
728x90
'Algorithm\CodingTest > Baekjoon' 카테고리의 다른 글
[Baekjoon] [1157] 단어 공부 (0) | 2023.02.09 |
---|---|
[Baekjoon] [4344] 평균은 넘겠지 (0) | 2023.02.09 |
[Baekjoon] [10926] ??! (0) | 2023.02.09 |
[Baekjoon] [18108] 1998년생인 내가 태국에서는 2541년생?! (0) | 2023.02.09 |
[Baekjoon] [25304] 영수증 (0) | 2023.02.09 |