Notice
Recent Posts
Recent Comments
Today
Total
01-26 19:30
Link
๊ด€๋ฆฌ ๋ฉ”๋‰ด

๋ชฉ๋ก๐Ÿ”ฅ Algorithm || ๋ฌธ์ œํ’€์ด (110)

Partially Committed

[2022 KAKAO BLIND RECRUITMENT] ์‹ ๊ณ ๊ฒฐ๊ณผ๋ฐ›๊ธฐ

https://programmers.co.kr/learn/courses/30/lessons/92334 ์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์—ฐ์Šต - ์‹ ๊ณ  ๊ฒฐ๊ณผ ๋ฐ›๊ธฐ ๋ฌธ์ œ ์„ค๋ช… ์‹ ์ž…์‚ฌ์› ๋ฌด์ง€๋Š” ๊ฒŒ์‹œํŒ ๋ถˆ๋Ÿ‰ ์ด์šฉ์ž๋ฅผ ์‹ ๊ณ ํ•˜๊ณ  ์ฒ˜๋ฆฌ ๊ฒฐ๊ณผ๋ฅผ ๋ฉ”์ผ๋กœ ๋ฐœ์†กํ•˜๋Š” ์‹œ์Šคํ…œ์„ ๊ฐœ๋ฐœํ•˜๋ ค ํ•ฉ๋‹ˆ๋‹ค. ๋ฌด์ง€๊ฐ€ ๊ฐœ๋ฐœํ•˜๋ ค๋Š” ์‹œ์Šคํ…œ์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค. ๊ฐ ์œ ์ €๋Š” ํ•œ ๋ฒˆ์— ํ•œ ๋ช…์˜ programmers.co.kr string(id), set (id ๋ฅผ ์‹ ๊ณ ํ•œ ์‚ฌ๋žŒ๋“ค)์„ key - value ๋กœ ๊ฐ€์ง€๋Š” unordered_map ์„ ์‚ฌ์šฉํ•œ๋‹ค. ํ•œ ์œ ์ €๊ฐ€ ๋‹ค๋ฅธ ์œ ์ €๋ฅผ 2๋ฒˆ ์ด์ƒ ์‹ ๊ณ ํ•œ ๊ฒƒ์€ 1๋ฒˆ์œผ๋กœ ์ฒ˜๋ฆฌํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์ค‘๋ณต์„ ์ œ๊ฑฐํ•˜๋Š” set ์„ ์‚ฌ์šฉํ•œ๋‹ค. report ๋ฐฐ์—ด์€ ๋„์›Œ์“ฐ๊ธฐ๋กœ ๊ตฌ๋ถ„๋˜์–ด ์ •๋ณด๊ฐ€ ๋“ค์–ด์˜จ๋‹ค. (์‹ ๊ณ ํ•œ์‚ฌ๋žŒ ์‹ ๊ณ ๋ฐ›์€์‚ฌ๋žŒ) ๊ทธ๋Ÿฌ๋ฏ€๋กœ ๊ณต๋ฐฑ์„ ๊ธฐ์ค€์œผ๋กœ ๋ฌธ์ž์—ด ํŒŒ..

[c++]Associate container

ํ•™๋ถ€์ƒ์ด ๊ณต๋ถ€ ๊ธฐ๋ก ์ฐจ์›์—์„œ ์ž‘์„ฑํ•œ ๊ธ€์ž…๋‹ˆ๋‹ค. ์–ธ์ œ๋‚˜ ์ง€์ ์€ ํ™˜์˜์ž…๋‹ˆ๋‹ค. Associate container key - value ๋ฅผ ํ†ตํ•ด์„œ ์„œ๋กœ ๊ด€๊ณ„์žˆ๋Š” ๊ฐ’์„ ๋ฌถ์–ด ์ €์žฅํ•˜๋Š” ์ปจํ…Œ์ด๋„ˆ๋ฅผ ๋งํ•œ๋‹ค. key ๊ฐ’์„ ํ†ตํ•ด์„œ ๊ฐ๊ฐ์˜ record ์— ๋น ๋ฅด๊ฒŒ ์ ‘๊ทผ์ด ๊ฐ€๋Šฅํ•˜์ง€๋งŒ specific ํ•œ rule ์— ์˜ํ•ด sorting ๋˜๊ธฐ ๋•Œ๋ฌธ์— insert ํ•  key ๊ฐ’์˜ ์œ„์น˜๋ฅผ ์ง€์ •ํ•  ์ˆ˜ ์—†๋‹ค. balanced binary search tree ๋‚˜ hash function ์„ ์‚ฌ์šฉํ•˜์—ฌ ๊ตฌํ˜„๋œ๋‹ค๊ณ  ํ•œ๋‹ค. std::set balanced binary tree ๋กœ ๊ตฌํ˜„๋˜์–ด ์žˆ๋Š” ์ •๋ ฌ๋œ ์ง‘ํ•ฉ์„ ํฌํ•จํ•˜๋Š” associate container ์ด๋‹ค. ์ค‘๋ณต๋˜๋Š” ์š”์†Œ๋ฅผ ํ—ˆ์šฉํ•˜์ง€ ์•Š๋Š”๋‹ค. ์˜ค๋ฆ„์ฐจ์ˆœ์œผ๋กœ ์ •๋ ฌ๋œ ์œ„์น˜์— ์›์†Œ๋ฅผ ์‚ฝ์ž…ํ•˜๊ธฐ ๋•Œ๋ฌธ์— ..