Seize your moment! ๐Ÿ‘พ

์•ˆ๋…•ํ•˜์„ธ์š”. Eric์ž…๋‹ˆ๋‹ค. ์ œ ๋ธ”๋กœ๊ทธ์— ๋ฐฉ๋ฌธํ•ด์ฃผ์…”์„œ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค.

๐Ÿ’ป ๊ฐœ๋ฐœ๊ณต๋ถ€/Algorithm

[Eric's ๋ฐฑ์ค€] 14425๋ฒˆ - ๋ฌธ์ž์—ด ์ง‘ํ•ฉ - Java

Eric_ko 2023. 2. 1. 19:59

 

์˜ค๋Š˜ ํ’€์–ด๋ณผ ๋ฌธ์ œ๋Š”

์ง‘ํ•ฉ๊ณผ ๋งต์ด๋ผ๋Š” ๋ฐฑ์ค€ 14425๋ฒˆ ๋ฌธ์ œ์ž…๋‹ˆ๋‹ค.

์ €๋Š” ์˜ค๋Š˜๋ถ€ํ„ฐ Scanner ๋Œ€์‹ ์— Buffered ~ ๋ฅผ ์‚ฌ์šฉ ํ•˜๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค!

 

ํ•ด๋‹น ๋ฌธ์ œ์—์„œ ์ œ๊ฐ€ ํ’€์—ˆ๋˜ ๋ฐฉ์‹์€

ํ•ด์‰ฌ๋งต์„ ์ด์šฉํ•˜์˜€์Šต๋‹ˆ๋‹ค.

์ฃผ์–ด์ง„ ๋ฌธ์ž๋ฅผ ์šฐ์„  HashMap ์— n๊ฐœ ๋„ฃ์€ ํ›„

m ๊ฐœ์˜ ๋ฌธ์ž๋ฅผ 

Hashmap ์˜ containsKey ๋ฅผ ์ด์šฉํ•˜์—ฌ count ํ•˜์˜€์Šต๋‹ˆ๋‹ค.

 

์ œ๊ฐ€ ํ‘ผ ๋ฐฉ์‹์€ ํ•˜๋‹จ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.

key ๊ฐ’์„ String ๊ฐ’์œผ๋กœ ๋„ฃ์—ˆ์œผ๋ฉฐ,

value ๊ฐ’์€ ๊ทธ๋ƒฅ ์˜๋ฏธ ์—†๋Š” 0์„ ๋„ฃ์—ˆ์Šต๋‹ˆ๋‹ค.

 

Solved.ac ํ”„๋กœํ•„