[JavaScript/BOJ] 1181 - ๋‹จ์–ด ์ •๋ ฌ
ยท
Algorithm/๋ฐฑ์ค€(BOJ)
๐Ÿ“Œ ๋ฌธ์ œ(์ •๋ ฌ ์•Œ๊ณ ๋ฆฌ์ฆ˜) 1181๋ฒˆ: ๋‹จ์–ด ์ •๋ ฌ ์ฒซ์งธ ์ค„์— ๋‹จ์–ด์˜ ๊ฐœ์ˆ˜ N์ด ์ฃผ์–ด์ง„๋‹ค. (1 ≤ N ≤ 20,000) ๋‘˜์งธ ์ค„๋ถ€ํ„ฐ N๊ฐœ์˜ ์ค„์— ๊ฑธ์ณ ์•ŒํŒŒ๋ฒณ ์†Œ๋ฌธ์ž๋กœ ์ด๋ฃจ์–ด์ง„ ๋‹จ์–ด๊ฐ€ ํ•œ ์ค„์— ํ•˜๋‚˜์”ฉ ์ฃผ์–ด์ง„๋‹ค. ์ฃผ์–ด์ง€๋Š” ๋ฌธ์ž์—ด์˜ ๊ธธ์ด๋Š” 50์„ ๋„˜์ง€ ์•Š๋Š”๋‹ค. www.acmicpc.net ๐Ÿ“ ํ’€์ด const fs = require('fs'); const input = fs.readFileSync('/dev/stdin').toString().trim().split('\n'); function solution(input) { let answer; const [size, ...arr] = input; // ๊ฐ™์€ ๋‹จ์–ด๊ฐ€ ์—ฌ๋Ÿฌ ๋ฒˆ ์ž…๋ ฅ๋œ ๊ฒฝ์šฐ์—๋Š” ํ•œ ๋ฒˆ์”ฉ๋งŒ ์ถœ๋ ฅ let newArr = [...new Set(arr)]; ..
_์„ฑํ˜ธ_
'1181๋ฒˆ ๋‹จ์–ด ์ •๋ ฌ' ํƒœ๊ทธ์˜ ๊ธ€ ๋ชฉ๋ก