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

3๋‹จ๊ณ„35

[Swift] ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ๊ธฐ์ง€๊ตญ ์„ค์น˜ Problem ์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์—ฐ์Šต - ๊ธฐ์ง€๊ตญ ์„ค์น˜ N๊ฐœ์˜ ์•„ํŒŒํŠธ๊ฐ€ ์ผ๋ ฌ๋กœ ์ญ‰ ๋Š˜์–ด์„œ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด ์ค‘์—์„œ ์ผ๋ถ€ ์•„ํŒŒํŠธ ์˜ฅ์ƒ์—๋Š” 4g ๊ธฐ์ง€๊ตญ์ด ์„ค์น˜๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค. ๊ธฐ์ˆ ์ด ๋ฐœ์ „ํ•ด 5g ์ˆ˜์š”๊ฐ€ ๋†’์•„์ ธ 4g ๊ธฐ์ง€๊ตญ์„ 5g ๊ธฐ์ง€๊ตญ์œผ๋กœ ๋ฐ”๊พธ๋ ค ํ•ฉ๋‹ˆ๋‹ค. ๊ทธ๋Ÿฐ๋ฐ 5 programmers.co.kr Solution 1. stations๋ฅผ ์ˆœํšŒํ•˜๋ฉฐ ์ „ํŒŒ๊ฐ€ ์˜ค์ง€ ์•Š๋Š” ๊ตฌ๊ฐ„์„ ๊ตฌํ•ฉ๋‹ˆ๋‹ค. ์ „ํŒŒ๊ฐ€ ์•ˆ์˜ค๋Š” ๊ตฌ๊ฐ„์€ ํ˜„์žฌ ์„ค์น˜๋œ ๊ธฐ์ง€๊ตญ๋“ค์˜ ์ „ํŒŒ ๋„๋‹ฌ๊ฑฐ๋ฆฌ ์‚ฌ์ด์ž…๋‹ˆ๋‹ค. ๋ฌธ์ œ์— ๋‚˜์™”๋˜ ์˜ˆ๋กœ ๋“ค๋ฉด 4์™€ 11์— ํ˜„์žฌ ๊ธฐ์ง€๊ตญ๋“ค์ด ์„ค์น˜๋˜์–ด ์žˆ๊ณ  ์ „ํŒŒ ๋„๋‹ฌ๊ฑฐ๋ฆฌ ์‚ฌ์ด๋Š” 1~2, 6~9 ์ž…๋‹ˆ๋‹ค. 2. ์ „ํŒŒ๊ฐ€ ์˜ค์ง€ ์•Š๋Š” ๊ตฌ๊ฐ„์— ๊ธฐ์ง€๊ตญ์ด ๋ช‡ ๊ฐœ ํ•„์š”ํ•œ์ง€ ๊ณ„์‚ฐํ•œ๋‹ค. ์ „ํŒŒ๊ฐ€ ์˜ค์ง€ ์•Š๋Š” ๊ตฌ๊ฐ„์˜ ์ˆ˜๊ฐ€ n์ด๋ผ๋ฉด ํ•„์š”ํ•œ ๊ธฐ์ง€๊ตญ์˜ ์ˆ˜๋Š” n/w*2+1 ์„ ์˜ฌ๋ฆผํ•œ ์ˆ˜์ž…๋‹ˆ๋‹ค... 2021. 9. 10.
[Swift] 2020 KAKAO BLIND RECRUITMENT ์™ธ๋ฒฝ ์ ๊ฒ€ Problem ์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์—ฐ์Šต - ์™ธ๋ฒฝ ์ ๊ฒ€ ๋ ˆ์Šคํ† ๋ž‘์„ ์šด์˜ํ•˜๊ณ  ์žˆ๋Š” "์Šค์นดํ”ผ"๋Š” ๋ ˆ์Šคํ† ๋ž‘ ๋‚ด๋ถ€๊ฐ€ ๋„ˆ๋ฌด ๋‚ก์•„ ์นœ๊ตฌ๋“ค๊ณผ ํ•จ๊ป˜ ์ง์ ‘ ๋ฆฌ๋ชจ๋ธ๋ง ํ•˜๊ธฐ๋กœ ํ–ˆ์Šต๋‹ˆ๋‹ค. ๋ ˆ์Šคํ† ๋ž‘์ด ์žˆ๋Š” ๊ณณ์€ ์Šค๋…ธ์šฐํƒ€์šด์œผ๋กœ ๋งค์šฐ ์ถ”์šด ์ง€์—ญ์ด์–ด์„œ ๋‚ด๋ถ€ ๊ณต์‚ฌ๋ฅผ ํ•˜ programmers.co.kr Solution 1. Set๋กœ ๋œ ์ทจ์•ฝ์ ๋“ค์ด ๋‹ด์„ weaks ๋ณ€์ˆ˜๋ฅผ ๋งŒ๋“ค์–ด์ค๋‹ˆ๋‹ค. Set๋กœ ๋งŒ๋“ค์–ด์ฃผ๋Š” ์ด์œ ๋Š” ์ทจ์•ฝ์ ๋“ค์ด ๊ฐ™์€ ๊ฒƒ๋“ค์˜ ๋ฐ˜๋ณต์„ ํ”ผํ•˜๊ธฐ ์œ„ํ•ด์„œ์ž…๋‹ˆ๋‹ค.(์‹œ๊ฐ„์ดˆ๊ณผ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•ด) var weaks:Set = [weak] 2. ์ด๋™ํ•  ์ˆ˜ ์žˆ๋Š” ๊ฑฐ๋ฆฌ๊ฐ€ ํฐ ์นœ๊ตฌ๋ถ€ํ„ฐ ์ฐจ๋ก€๋กœ ์ˆœํšŒํ•œ๋‹ค. ์ตœ๋Œ€ํ•œ ์ ์€ ์นœ๊ตฌ๋ฅผ ์ด์šฉํ•ด์•ผ ํ•˜๋ฏ€๋กœ ๊ฑฐ๋ฆฌ๊ฐ€ ํฐ ์นœ๊ตฌ๋ถ€ํ„ฐ ์ˆœํšŒํ•ฉ๋‹ˆ๋‹ค. for (i,d) in dist.reversed().enumerated() { ... 3. ์ด๋ฏธ .. 2021. 9. 8.
[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 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] ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค N-Queen Problem ์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์—ฐ์Šต - N-Queen ๊ฐ€๋กœ, ์„ธ๋กœ ๊ธธ์ด๊ฐ€ n์ธ ์ •์‚ฌ๊ฐํ˜•์œผ๋กœ๋œ ์ฒด์ŠคํŒ์ด ์žˆ์Šต๋‹ˆ๋‹ค. ์ฒด์ŠคํŒ ์œ„์˜ n๊ฐœ์˜ ํ€ธ์ด ์„œ๋กœ๋ฅผ ๊ณต๊ฒฉํ•  ์ˆ˜ ์—†๋„๋ก ๋ฐฐ์น˜ํ•˜๊ณ  ์‹ถ์Šต๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด์„œ n์ด 4์ธ๊ฒฝ์šฐ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ํ€ธ์„ ๋ฐฐ์น˜ํ•˜๋ฉด n๊ฐœ์˜ ํ€ธ์€ programmers.co.kr Solution ํ•ด๋‹น ๋ฌธ์ œ๋Š” ๋ฐฑํŠธ๋ž˜ํ‚น(DFS)์œผ๋กœ ํ’€์–ด์•ผ ํ•˜๋Š” ๋ฌธ์ œ์ž…๋‹ˆ๋‹ค. 1. ๊ฐ ํ–‰๋งˆ๋‹ค ํ€ธ์„ ๋†“์„ ์ˆ˜ ์žˆ๋Š” ์œ„์น˜๋ฅผ ์ฒดํฌํ•œ๋‹ค. ๊ฐ ํ–‰๋งˆ๋‹ค ํ€ธ์€ ํ•˜๋‚˜์”ฉ๋ฐ–์— ๋ชป๋†“์œผ๋ฏ€๋กœ ํ˜„์žฌ ํ–‰์˜ ์—ด๋“ค์— ๊ณต๊ฒฉํ•  ์ˆ˜ ์žˆ๋Š” ํ€ธ์ด ์žˆ๋Š”์ง€ ์ฒดํฌํ•ฉ๋‹ˆ๋‹ค. ๋งŒ์•ฝ ๊ณต๊ฒฉํ•  ์ˆ˜ ์žˆ๋Š” ํ€ธ์ด ์—†๋‹ค๋ฉด ํ˜„์žฌ ์œ„์น˜๋ฅผ history(ํ€ธ์˜ ์œ„์น˜๋ฅผ ์ €์žฅํ•˜๋Š” 2์ฐจ์› ๋ฐฐ์—ด)์— ์ €์žฅํ•ด๋†“๊ณ  ๋‹ค์Œ ํ–‰์œผ๋กœ ์ง„ํ–‰ํ•ฉ๋‹ˆ๋‹ค. ์ด๋ ‡๊ฒŒ ์ง„ํ–‰ํ•˜๋ฉด์„œ ๊ฐ€์žฅ ๋งˆ์ง€๋ง‰ ํ–‰๊นŒ์ง€ ๋„๋‹ฌํ•œ ๊ฒฝ์šฐ๋Š” ๋ฐฐ์น˜ํ•  ์ˆ˜ ์žˆ๋Š” ๊ฒฝ์šฐ์ด๋ฏ€๋กœ.. 2021. 8. 28.
[Swift] ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ์œ„ํด๋ฆฌ ์ฑŒ๋ฆฐ์ง€ 3์ฃผ์ฐจ ํผ์ฆ ์กฐ๊ฐ ์ฑ„์šฐ๊ธฐ Problem ์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์—ฐ์Šต - 3์ฃผ์ฐจ [[1,1,0,0,1,0],[0,0,1,0,1,0],[0,1,1,0,0,1],[1,1,0,1,1,1],[1,0,0,0,1,0],[0,1,1,1,0,0]] [[1,0,0,1,1,0],[1,0,1,0,1,0],[0,1,1,0,1,1],[0,0,1,0,0,0],[1,1,0,1,1,0],[0,1,0,0,0,0]] 14 [[0,0,0],[1,1,0],[1,1,1]] [[1,1,1],[1,0,0],[0,0,0]] 0 programmers.co.kr Solution 1. ๊ฒŒ์ž„๋ณด๋“œ์™€ ํ…Œ์ด๋ธ”์˜ ํผ์ฆ ์กฐ๊ฐ๋“ค์„ ์ฐพ๋Š”๋‹ค. ๊ฒŒ์ž„๋ณด๋“œ์™€ ํ…Œ์ด๋ธ”์˜ ํผ์ฆ ์กฐ๊ฐ๋“ค์„ ์ฐพ๊ธฐ ์œ„ํ•ด์„  BFS ์•Œ๊ณ ๋ฆฌ์ฆ˜์„ ์‚ฌ์šฉํ•ด์•ผ ๋ฉ๋‹ˆ๋‹ค. ๊ฒŒ์ž„๋ณด๋“œ๋ฅผ ํƒ์ƒ‰ํ•  ๋• ๋งŒ์•ฝ 0์„ ๋งŒ๋‚˜๊ฒŒ ๋˜์—ˆ๋‹ค๋ฉด ๊ทธ ์ฃผ๋ณ€ ์™ผ์ชฝ,์˜ค๋ฅธ์ชฝ,์œ„,์•„๋ž˜๊ฐ€ 0.. 2021. 8. 20.
[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] 2018 KAKAO BLIND RECRUITMENT [1์ฐจ] ์…”ํ‹€๋ฒ„์Šค Problem ์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์—ฐ์Šต - [1์ฐจ] ์…”ํ‹€๋ฒ„์Šค 10 60 45 ["23:59","23:59", "23:59", "23:59", "23:59", "23:59", "23:59", "23:59", "23:59", "23:59", "23:59", "23:59", "23:59", "23:59", "23:59", "23:59"] "18:00" programmers.co.kr Solution 1.timetable์„ ์ ์€ ์‹œ๊ฐ„ ์ˆœ์œผ๋กœ ์ •๋ ฌํ•œ๋‹ค. var times:[Int] = timetable.map{Int($0.split(separator: ":")[0])!*60 + Int($0.split(separator: ":")[1])!}.sorted(by: 2021. 8. 6.
[Swift] 2020 KAKAO INTERNSHIP ๋ณด์„ ์‡ผํ•‘ Problem ์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์—ฐ์Šต - ๋ณด์„ ์‡ผํ•‘ ["DIA", "RUBY", "RUBY", "DIA", "DIA", "EMERALD", "SAPPHIRE", "DIA"] [3, 7] programmers.co.kr Solution ํ•ด๋‹น ๋ฌธ์ œ๋Š” ๋”•์…”๋„ˆ๋ฆฌ์™€ ํˆฌํฌ์ธํŠธ๋กœ ํ’€์–ด์•ผ ํ•˜๋Š” ๋ฌธ์ œ์ž…๋‹ˆ๋‹ค. 1.Set๋ฅผ ์ด์šฉํ•ด ๋ชจ๋“  ๋ณด์„์˜ ๊ฐœ์ˆ˜๋ฅผ ์„ธ์ค๋‹ˆ๋‹ค. Set(gems)์˜ ๊ฐœ์ˆ˜๋ฅผ ์„ธ์ค๋‹ˆ๋‹ค. 2. ํฌ์ธํ„ฐ ๋‘ ๊ฐœ(First,Last)๋ฅผ ์ฒซ๋ฒˆ์งธ๋กœ ์„ธํŒ…ํ•ด์ค๋‹ˆ๋‹ค. 3. ๋”•์…”๋„ˆ๋ฆฌ๋ฅผ ์ด์šฉํ•ด ๋ณด์„์„ ์ €์žฅํ•ด์ค๋‹ˆ๋‹ค. ๋ณด์„์˜ ์ด๋ฆ„์„ key๊ฐ’์œผ๋กœ ๋ณด์„์˜ ์œ„์น˜๋ฅผ value๊ฐ’์œผ๋กœ ์ €์žฅํ•ด์ค๋‹ˆ๋‹ค. ex) ["DIA":[0,3,4,7],"RUBY":[1,2],"EMERALD":[5]] 4.๋ชจ๋“  ๋ณด์„์ด ์žˆ๋Š”์ง€ ์—†๋Š”์ง€ ํ™•์ธ ํ›„ ํฌ์ธํ„ฐ๋ฅผ ์ด๋™ํ•ด์ค๋‹ˆ๋‹ค. ๋ชจ๋“  .. 2021. 8. 4.
[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.
[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.
728x90
๋ฐ˜์‘ํ˜•