알고리즘 (with. 백준 문제풀이)/Hash Map & Set2 백준 25192번 [인사성 밝은 곰곰이] const input = require('fs') .readFileSync('/dev/stdin') .toString() .trim() .split('\n') const [n, ...test] = input const hashSet = new Set(); let answer = 0; test.map((str) => { if(str == "ENTER"){ answer += hashSet.size hashSet.clear() } else{ hashSet.add(str); } }) answer += hashSet.size console.log(answer) 문자열과 나온 횟수를 map으로 풀려고 시도하다가 set으로 접근하니까 쉽게 풀렸던 문제 2023. 9. 21. 백준 17219번 [비밀번호 찾기] const input = require('fs') .readFileSync('/dev/stdin') .toString() .trim() .split('\n') const [n, m] = input.shift().split(' ') const map = new Map() for(let i=0; i 2023. 9. 19. 이전 1 다음