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

์นด์นด์˜ค16

[Swift] 2019 KAKAO BLIND RECRUITMENT ๋งค์นญ ์ ์ˆ˜ Problem ์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์—ฐ์Šต - ๋งค์นญ ์ ์ˆ˜ ๋งค์นญ ์ ์ˆ˜ ํ”„๋ Œ์ฆˆ ๋Œ€ํ•™๊ต ์กฐ๊ต์˜€๋˜ ์ œ์ด์ง€๋Š” ํ—ˆ๋“œ๋ ›์ผ๋งŒ ์‹œํ‚ค๋Š” ๋„ค์˜ค ํ•™๊ณผ์žฅ๋‹˜์˜ ๋งˆ์ˆ˜์—์„œ ๋ฒ—์–ด๋‚˜, ์นด์นด์˜ค์— ์ž…์‚ฌํ•˜๊ฒŒ ๋˜์—ˆ๋‹ค. ํ‰์†Œ์— ๊ด€์‹ฌ์žˆ์–ดํ•˜๋˜ ๊ฒ€์ƒ‰์— ๋งˆ์นจ ๊ฒฐ์›์ด ๋ฐœ์ƒํ•˜์—ฌ, ๊ฒ€์ƒ‰๊ฐœ๋ฐœํŒ€ programmers.co.kr Solution 1. ํŽ˜์ด์ง€์— ํ•„์š”ํ•œ ์ •๋ณด๋ฅผ ๋‹ด๋Š” ๊ฐ์ฒด๋ฅผ ๋งŒ๋“ค์–ด์ค€๋‹ค. ๋ช‡๋ฒˆ์งธ ์ธ๋ฑ์Šค์ธ์ง€,์ž์‹ ์˜ url,์ด ์ ์ˆ˜,์™ธ๋ถ€ ๋งํฌ๋ฅผ ํ”„๋กœํผํ‹ฐ๋กœ ์„ค์ •ํ•ด์ค๋‹ˆ๋‹ค. struct Page { var index:Int, url:String,score:Double,externalLinks:[String] } 2. " Int { for pageInfo in pageInfos { for link in pageInfo.externalLinks { if let index = p.. 2021. 9. 4.
[Swift] 2020 KAKAO BLIND RECRUITMENT ๊ธฐ๋‘ฅ๊ณผ ๋ณด ์„ค์น˜ํ•˜๊ธฐ Problem ์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์—ฐ์Šต - ๊ธฐ๋‘ฅ๊ณผ ๋ณด ์„ค์น˜ 5 [[1,0,0,1],[1,1,1,1],[2,1,0,1],[2,2,1,1],[5,0,0,1],[5,1,0,1],[4,2,1,1],[3,2,1,1]] [[1,0,0],[1,1,1],[2,1,0],[2,2,1],[3,2,1],[4,2,1],[5,0,0],[5,1,0]] 5 [[0,0,0,1],[2,0,0,1],[4,0,0,1],[0,1,1,1],[1,1,1,1],[2,1,1,1],[3,1,1,1],[2,0,0,0],[1,1,1,0],[2,2,0,1]] [[ programmers.co.kr Solution 1. ๊ธฐ๋‘ฅ์„ ์ถ”๊ฐ€ํ•  ๋•Œ ์ ํ•ฉํ•œ์ง€ ํ™•์ธํ•œ๋‹ค. ๋ฐ”๋‹ฅ,๊ธฐ๋‘ฅ ์œ„,๋ณด์˜ ์œ„์ผ ๊ฒฝ์šฐ ์„ค์น˜ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. func checkRightPillars(x:Int,y:In.. 2021. 8. 13.
[Swift] 2020 KAKAO BLIND RECRUITMENT ๋ธ”๋ก ์ด๋™ํ•˜๊ธฐ Problem ์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์—ฐ์Šต - ๋ธ”๋ก ์ด๋™ํ•˜๊ธฐ [[0, 0, 0, 1, 1],[0, 0, 0, 1, 0],[0, 1, 0, 1, 1],[1, 1, 0, 0, 1],[0, 0, 0, 0, 0]] 7 programmers.co.kr Solution ํ•ด๋‹น ๋ฌธ์ œ๋Š” BFS๋กœ ํ’€์–ด์•ผํ•˜๋Š” ๋ฌธ์ œ์ž…๋‹ˆ๋‹ค. 1. ํ˜„์žฌ ์œ„์น˜, ์›€์ง์ผ ๋ช…๋ น, ๋ฐฉํ–ฅ์„ ์ดˆ๊ธฐํ™”ํ•ด์ค๋‹ˆ๋‹ค. struct Current { var x:Int,y:Int,d:Direction,count:Int,past:Command } enum Command:CaseIterable { case up,down,left,right,rotateClockwise,rotateAntiClockwise,rotateClockwise2,rotateAntiClockwise2 } enum D.. 2021. 8. 3.
[Swift] 2019 KAKAO WINTER INTERNSHIP ์ง•๊ฒ€๋‹ค๋ฆฌ ๊ฑด๋„ˆ๊ธฐ Problem ์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์—ฐ์Šต - ์ง•๊ฒ€๋‹ค๋ฆฌ ๊ฑด๋„ˆ๊ธฐ [2, 4, 5, 3, 2, 1, 4, 2, 5, 1] 3 3 programmers.co.kr Solution ํ•ด๋‹น ๋ฌธ์ œ๋Š” ์ด์ง„ํƒ์ƒ‰์œผ๋กœ ํ’€์–ด์•ผ ํ•˜๋Š” ๋ฌธ์ œ์ž…๋‹ˆ๋‹ค. 1. stones์˜ ์ˆซ์ž๋ฅผ ์˜ค๋ฆ„์ฐจ์ˆœ ์ •๋ ฌํ•œ ๋’ค ์ค‘๋ณต ์ˆซ์ž๋ฅผ ์ œ๊ฑฐํ•œ๋‹ค. stones๋ฅผ Set๋กœ ๋งŒ๋“ค๊ณ  sorted ๋ฉ”์†Œ๋“œ๋กœ ์ •๋ ฌํ•ด์ค๋‹ˆ๋‹ค. (sort๋ผ๊ณ  ๋ถ€๋ฅด๊ฒ ์Šต๋‹ˆ๋‹ค.) (ex [1,1,5,3,2,2] -> [1,2,3,5]) 2. ๊ฑด๋„ ์ˆ˜ ์žˆ๋Š”์ง€ ์—†๋Š”์ง€ ์ฒดํฌํ•ฉ๋‹ˆ๋‹ค. 0์ดํ•˜์˜ ์ˆซ์ž์˜ ์—ฐ์†๋œ ๊ฐฏ์ˆ˜๊ฐ€ k๋ณด๋‹ค ๊ฐ™๊ฑฐ๋‚˜ ํฌ๋‹ค๋ฉด ๊ฑด๋„ ์ˆ˜ ์—†๋Š” ์ง•๊ฒ€๋‹ค๋ฆฌ์ž…๋‹ˆ๋‹ค. (ex [-1, 0, -2, 1, 0] -> ์—ฐ์†๋œ 0์ดํ•˜ ๊ฐฏ์ˆ˜๋Š” 3) 3. sort๋ฅผ ์ด์ง„ํƒ์ƒ‰ ์ด์ง„ ํƒ์ƒ‰์œผ๋กœ sort์•ˆ์˜ ์ˆซ์ž ์ค‘ ๊ฑด๋„ ์ˆ˜ ์žˆ๋Š” ๊ฐ€์žฅ ์ตœ.. 2021. 7. 23.
728x90
๋ฐ˜์‘ํ˜•