๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
728x90
๋ฐ˜์‘ํ˜•

KAKAO18

[Swift] 2022 KAKAO BLIND RECRUITMENT ์‹ ๊ณ  ๊ฒฐ๊ณผ ๋ฐ›๊ธฐ Problem ์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์—ฐ์Šต - ์‹ ๊ณ  ๊ฒฐ๊ณผ ๋ฐ›๊ธฐ ๋ฌธ์ œ ์„ค๋ช… ์‹ ์ž…์‚ฌ์› ๋ฌด์ง€๋Š” ๊ฒŒ์‹œํŒ ๋ถˆ๋Ÿ‰ ์ด์šฉ์ž๋ฅผ ์‹ ๊ณ ํ•˜๊ณ  ์ฒ˜๋ฆฌ ๊ฒฐ๊ณผ๋ฅผ ๋ฉ”์ผ๋กœ ๋ฐœ์†กํ•˜๋Š” ์‹œ์Šคํ…œ์„ ๊ฐœ๋ฐœํ•˜๋ ค ํ•ฉ๋‹ˆ๋‹ค. ๋ฌด์ง€๊ฐ€ ๊ฐœ๋ฐœํ•˜๋ ค๋Š” ์‹œ์Šคํ…œ์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค. ๊ฐ ์œ ์ €๋Š” ํ•œ ๋ฒˆ์— ํ•œ ๋ช…์˜ programmers.co.kr Solution 1. id_list๋ฅผ ์ธ๋ฑ์Šค์— ๋งž๊ฒŒ ๋”•์…”๋„ˆ๋ฆฌ์— ๋‹ด๋Š”๋‹ค. var idNumber:[String:Int] = [:] for (i,id) in id_list.enumerated() { idNumber[id] = i } 2. ์‹ ๊ณ  ๋‹นํ•œ ์‚ฌ๋žŒ์„ ํ‚ค๊ฐ’์œผ๋กœ,์‹ ๊ณ ํ•œ ์‚ฌ๋žŒ๋“ค์„ ๋ฐธ๋ฅ˜๊ฐ’์œผ๋กœ ๋”•์…”๋„ˆ๋ฆฌ์— ๋‹ด๋Š”๋‹ค. var reportInfo:[String:Set] = [:] for r in report { let split = r.split(sepa.. 2022. 1. 19.
[Swift] 2020 KAKAO BLIND RECRUITMENT ๊ฐ€์‚ฌ ๊ฒ€์ƒ‰  Problem ์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์—ฐ์Šต - ๊ฐ€์‚ฌ ๊ฒ€์ƒ‰ programmers.co.kr Solution ํ•ด๋‹น ๋ฌธ์ œ๋Š” Trie ์ž๋ฃŒ๊ตฌ์กฐ๋ฅผ ์‚ฌ์šฉํ•ด์„œ ํ’€์–ด์•ผ ํ•˜๋Š” ๋ฌธ์ œ์ž…๋‹ˆ๋‹ค. (Trie ๊ด€๋ จํ•ด์„œ๋Š” ๋”ฐ๋กœ ์ •๋ฆฌํ•ด์„œ ์˜ฌ๋ฆฌ๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค!ใ…œ) 1. Trie ์ž๋ฃŒ ๊ตฌ์กฐ๋ฅผ ๋งŒ๋“ค์–ด์ค€๋‹ค. ์ •์„์œผ๋กœ ๋งŒ๋“ ๊ฑด ์•„๋‹ˆ๊ณ  ๊ฐ„๋‹จํ•˜๊ฒŒ ๋‹จ์–ด๋ฅผ Trie ์ž๋ฃŒ๊ตฌ์กฐ์— ๋งž๊ฒŒ ์‚ฝ์ž…ํ•˜๋Š” insert ๋ฉ”์„œ๋“œ์™€ ๊ธ€์ž์˜ ์ž์‹์ด ๋ช‡ ๊ฐœ ์žˆ๋Š”์ง€ ์„ธ์–ด์ฃผ๋Š” getCount ๋ฉ”์„œ๋“œ๋ฅผ ๊ตฌํ˜„ํ–ˆ์Šต๋‹ˆ๋‹ค. class Node { var value:String var count:Int = 0 var children:[String:Node] = [:] init(value:String) { self.value = value } func append(_ value:String) { se.. 2022. 1. 3.
[Swift] 2019 KAKAO BLIND RECRUITMENT ๋ฌด์ง€์˜ ๋จน๋ฐฉ ๋ผ์ด๋ธŒ Problem ์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์—ฐ์Šต - ๋ฌด์ง€์˜ ๋จน๋ฐฉ ๋ผ์ด๋ธŒ programmers.co.kr Solution ํ•ด๋‹น ๋ฌธ์ œ๋Š” ํšจ์œจ์„ฑ์ด ํ•ต์‹ฌ์ธ ๋ฌธ์ œ์ž…๋‹ˆ๋‹ค. food_times๊ฐ€ ์ตœ๋Œ€ 1์–ต, k๊ฐ€ ์ตœ๋Œ€ 2*10^13์ด๊ธฐ ๋•Œ๋ฌธ์— ๋‹จ์ˆœํžˆ 0์ดˆ๋ถ€ํ„ฐ ์‹œ๊ฐ„์„ ์žฌ๋ฉฐ ์Œ์‹์„ ํ™•์ธํ•˜๊ธฐ์—” ๋„ˆ๋ฌด ํฐ ์‹œ๊ฐ„์ด ๊ฑธ๋ฆฝ๋‹ˆ๋‹ค. 1. ์Œ์‹์ด ๋‚จ์ง€ ์•Š๋Š” ๊ฒฝ์šฐ๋ฅผ ์ •์˜ํ•œ๋‹ค. ์Œ์‹์„ ๋จน๋Š” ์‹œ๊ฐ„์„ ๋ชจ๋‘ ํ•ฉ์ณ๋„ k๋ณด๋‹ค ์ž‘๊ฑฐ๋‚˜ ๊ฐ™์œผ๋ฉด k์‹œ๊ฐ„์— ๋‚จ๋Š” ์Œ์‹์ด ์—†์Šต๋‹ˆ๋‹ค. if food_times.reduce(0,+) $1.element} 3. ๋‚จ์€ ์Œ์‹ ์ˆ˜์™€ ์ตœ์†Œ ์‹œ๊ฐ„์„ ๊ณฑํ•˜์—ฌ k์—์„œ ๋นผ์ค€๋‹ค. ํ•œ๋ฒˆ์— ์Œ์‹ ์ˆ˜๋ฅผ ๊ฐ€์žฅ ๋งŽ์ด ๋บ„ ์ˆ˜ ์žˆ๋Š” ๊ฒƒ์€ ํ˜„์žฌ ๋‚จ์€ ์Œ์‹ ์ˆ˜์™€ ๊ฐ€์žฅ ์ตœ์†Œ๊ฐ’์„ ๊ณฑํ•ด์ฃผ๋ฉด ๋ฉ๋‹ˆ๋‹ค. ์ฆ‰, [3,5,6,7,8,9,4,4,3,3]๊ฐ€ ์žˆ๋‹ค๊ณ  ๊ฐ€์ •ํ•˜๋ฉด ํ˜„์žฌ ๋‚จ์€ .. 2021. 12. 15.
[Swift] 2020 KAKAO INTERNSHIP ๊ฒฝ์ฃผ๋กœ ๊ฑด์„ค Problem ์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์—ฐ์Šต - ๊ฒฝ์ฃผ๋กœ ๊ฑด์„ค [[0,0,0,0,0,0,0,1],[0,0,0,0,0,0,0,0],[0,0,0,0,0,1,0,0],[0,0,0,0,1,0,0,0],[0,0,0,1,0,0,0,1],[0,0,1,0,0,0,1,0],[0,1,0,0,0,1,0,0],[1,0,0,0,0,0,0,0]] 3800 [[0,0,1,0],[0,0,0,0],[0,1,0,1],[1,0,0,0]] 2100 [[0,0,0,0,0,0],[0,1,1,1,1,0],[0,0,1,0,0,0],[1,0,0,1,0,1],[ programmers.co.kr Solution ํ•ด๋‹น ๋ฌธ์ œ๋Š” DFS๋กœ ํ’€์–ด์•ผ ํ•˜๋Š” ๋ฌธ์ œ์ž…๋‹ˆ๋‹ค. 1. ์ž๋™์ฐจ์™€ ์ƒํ•˜์ขŒ์šฐ ๋ฐฉํ–ฅ ๋ชจ๋ธ์„ ๋งŒ๋“ค์–ด์ค€๋‹ค. (ํ•„์ˆ˜๋Š” ์•„๋‹˜) ์ž๋™์ฐจ์— ํ•„์š”ํ•œ x,y,price,prev์™€ ์ƒ.. 2021. 8. 31.
[Swift] 2021 KAKAO INTERNSHIP ํ‘œํŽธ์ง‘ Problem ์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์—ฐ์Šต - ํ‘œ ํŽธ์ง‘ 8 2 ["D 2","C","U 3","C","D 4","C","U 2","Z","Z"] "OOOOXOOO" 8 2 ["D 2","C","U 3","C","D 4","C","U 2","Z","Z","U 1","C"] "OOXOXOOO" programmers.co.kr Solution ํ•ด๋‹น ๋ฌธ์ œ๋Š” Linked List ์ž๋ฃŒ๊ตฌ์กฐ๋ฅผ ์ด์šฉํ•ด์„œ ํ’€์–ด์•ผ ํ•˜๋Š” ๋ฌธ์ œ์ž…๋‹ˆ๋‹ค. 1. 0๋ถ€ํ„ฐ n๊นŒ์ง€ ์ž๊ธฐ ์ด์ „์˜ ์ˆซ์ž์™€ ๋‹ค์Œ ์ˆซ์ž๋ฅผ ๋ฐฐ์—ด์— ๋‹ด์•„๋†“์Šต๋‹ˆ๋‹ค. func setLinkedList(n:Int) { for i in 0.. Int { return linkedList[index][0] } func next(_ index:Int) -> Int{ return linkedList[inde.. 2021. 7. 18.
2018 KAKAO BLIND RECRUITMENT [3์ฐจ] ํŒŒ์ผ๋ช… ์ •๋ ฌ Swift ์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์—ฐ์Šต - [3์ฐจ] ํŒŒ์ผ๋ช… ์ •๋ ฌ ํŒŒ์ผ๋ช… ์ •๋ ฌ ์„ธ ์ฐจ๋ก€์˜ ์ฝ”๋”ฉ ํ…Œ์ŠคํŠธ์™€ ๋‘ ์ฐจ๋ก€์˜ ๋ฉด์ ‘์ด๋ผ๋Š” ๊ธฐ๋‚˜๊ธด ๋ธ”๋ผ์ธ๋“œ ๊ณต์ฑ„๋ฅผ ๋ฌด์‚ฌํžˆ ํ†ต๊ณผํ•ด ์นด์นด์˜ค์— ์ž…์‚ฌํ•œ ๋ฌด์ง€๋Š” ํŒŒ์ผ ์ €์žฅ์†Œ ์„œ๋ฒ„ ๊ด€๋ฆฌ๋ฅผ ๋งก๊ฒŒ ๋˜์—ˆ๋‹ค. ์ €์žฅ์†Œ ์„œ๋ฒ„์—๋Š” ํ”„๋กœ๊ทธ๋žจ programmers.co.kr Source Code 2020. 11. 19.
728x90
๋ฐ˜์‘ํ˜•