(1).백준 17011번 Cold Compress는 압축기법에 의해 표현해야 하는 문제로
for문 내부에서 count로 몇번 반복되었는지 체크하는 것 외에 특별한 조건 없이 해결했다.
const input = `4
+++===!!!!
777777......TTTTTTTTTTTT
(AABBC)
3.1415555`.split('\n')
const result = []
for(let i = 1 ; i < input.length ; i++){
const strList = []
let count = 1
for(let j = 0 ; j < input[i].length ; j++){
if(input[i][j] == input[i][j+1]){
count++
}
else{
strList.push(count)
strList.push(input[i][j])
count = 1
}
}
result.push(strList.join(' '))
}
console.log(result.join('\n'))'회고' 카테고리의 다른 글
| [개발일지] - 979 (0) | 2026.03.24 |
|---|---|
| [개발일지] - 978 (0) | 2026.03.23 |
| [개발일지] - 976 (0) | 2026.03.19 |
| [개발일지] - 975 (0) | 2026.03.19 |
| [개발일지] - 974 (0) | 2026.03.18 |