ํฐ์คํ ๋ฆฌ ๋ทฐ
๐ฅ ๋ฌธ์
๋ฌธ์ ์ค๋ช
์คํ์ด๋ค์ ๋งค์ผ ๋ค๋ฅธ ์ท์ ์กฐํฉํ์ฌ ์
์ด ์์ ์ ์์ฅํฉ๋๋ค.
์๋ฅผ ๋ค์ด ์คํ์ด๊ฐ ๊ฐ์ง ์ท์ด ์๋์ ๊ฐ๊ณ ์ค๋ ์คํ์ด๊ฐ ๋๊ทธ๋ ์๊ฒฝ, ๊ธด ์ฝํธ, ํ๋์ ํฐ์
์ธ ๋ฅผ ์
์๋ค๋ฉด ๋ค์๋ ์ ์ฒญ๋ฐ์ง๋ฅผ ์ถ๊ฐ๋ก ์
๊ฑฐ๋ ๋๊ทธ๋ ์๊ฒฝ ๋์ ๊ฒ์ ์ ๊ธ๋ผ์ค๋ฅผ ์ฐฉ์ฉํ๊ฑฐ๋ ํด์ผ ํฉ๋๋ค.
์คํ์ด๊ฐ ๊ฐ์ง ์์๋ค์ด ๋ด๊ธด 2์ฐจ์ ๋ฐฐ์ด clothes๊ฐ ์ฃผ์ด์ง ๋ ์๋ก ๋ค๋ฅธ ์ท์ ์กฐํฉ์ ์๋ฅผ return ํ๋๋ก solution ํจ์๋ฅผ ์์ฑํด์ฃผ์ธ์.
์ ํ์ฌํญ
- clothes์ ๊ฐ ํ์ [์์์ ์ด๋ฆ, ์์์ ์ข ๋ฅ]๋ก ์ด๋ฃจ์ด์ ธ ์์ต๋๋ค.
- ์คํ์ด๊ฐ ๊ฐ์ง ์์์ ์๋ 1๊ฐ ์ด์ 30๊ฐ ์ดํ์ ๋๋ค.
- ๊ฐ์ ์ด๋ฆ์ ๊ฐ์ง ์์์ ์กด์ฌํ์ง ์์ต๋๋ค.
- clothes์ ๋ชจ๋ ์์๋ ๋ฌธ์์ด๋ก ์ด๋ฃจ์ด์ ธ ์์ต๋๋ค.
- ๋ชจ๋ ๋ฌธ์์ด์ ๊ธธ์ด๋ 1 ์ด์ 20 ์ดํ์ธ ์์ฐ์์ด๊ณ ์ํ๋ฒณ ์๋ฌธ์ ๋๋ '_' ๋ก๋ง ์ด๋ฃจ์ด์ ธ ์์ต๋๋ค.
- ์คํ์ด๋ ํ๋ฃจ์ ์ต์ ํ ๊ฐ์ ์์์ ์ ์ต๋๋ค.
๐ค ํ์ด ๋ฐฉ๋ฒ
- [["yellow_hat", "headgear"], ["blue_sunglasses", "eyewear"], ["green_turban", "headgear"]]
- 1๊ฐ๋ง ์
์ ๊ฒฝ์ฐ
- yellow_hat
- blue_sunglasses
- green_turban
- 2๊ฐ๋ฅผ ์กฐํฉํ์ฌ ์
์ ๊ฒฝ์ฐ
- yellow_hat + blue_sunglasses
- green_turbam + blue_sunglasses
- 1๊ฐ๋ง ์
์ ๊ฒฝ์ฐ
headgear๋ 2๊ฐ, eyewear๋ 1๊ฐ์ด๋ค.
headgear๋ฅผ ์ ์
๋ ๊ฒฝ์ฐ์ ์ 1, eyewear๋ฅผ ์ ์
๋ ๊ฒฝ์ฐ์ ์๋ฅผ 1์ ๊ฐ๊ฐ ๋ํด์ฃผ๋ฉด headgear๋ 3๊ฐ, eyewear๋ 2๊ฐ๊ฐ ๋๋ค.
headgear์ ์์ eyewear์ ์๋ฅผ ๊ณฑํด์ฃผ๋ฉด ์ด 6๊ฐ์ ๊ฒฝ์ฐ์ ์๊ฐ ๋์จ๋ค.
์คํ์ด๋ ํ๋ฃจ์ ์ต์ ํ ๊ฐ์ ์์์ ์
์ด์ผ ํ๊ธฐ ๋๋ฌธ์ headgear์ eyewear๋ฅผ ๋ชจ๋ ์ ์
๋ ๊ฒฝ์ฐ์ ์ 1์ ๋นผ์ฃผ์ด์ผ ํ๋ค.
๋ฐ๋ผ์ 5๊ฐ์ ์กฐํฉ์ด ๊ฐ๋ฅํ๋ค.
- [["crow_mask", "face"], ["blue_sunglasses", "face"], ["smoky_makeup", "face"]]
- 1๊ฐ๋ง ์
์ ๊ฒฝ์ฐ
- crow_mask
- blue_sunglasses
- smoky_makup
- ๋ชจ๋ face์ ํด๋นํ๋ ์์์ด๊ธฐ ๋๋ฌธ์ ๋ ๊ฐ์ง ์ด์์ ์กฐํฉ์ด ๋ถ๊ฐ๋ฅํ๋ค.
- 1๊ฐ๋ง ์
์ ๊ฒฝ์ฐ
face๊ฐ 3๊ฐ์ด๊ธฐ ๋๋ฌธ์ ๊ฐ๊ฐ ํ๋์ฉ ์ ์ผ๋ฉด ๋๋ค. ๋ฐ๋ผ์ ๋ต์ 3์ด ๋๋ค.
- [["a", "a"], ["b", "b"], ["c", "c"]]
- 1๊ฐ๋ง ์
์ ๊ฒฝ์ฐ
- a
- b
- c
- 2๊ฐ๋ฅผ ์กฐํฉํ์ฌ ์
์ ๊ฒฝ์ฐ
- a + b
- a + c
- b + c
- 3๊ฐ๋ฅผ ์กฐํฉํ์ฌ ์
์ ๊ฒฝ์ฐ
- a + b + c
- 1๊ฐ๋ง ์
์ ๊ฒฝ์ฐ
a, b, c๊ฐ ๊ฐ๊ฐ 1๊ฐ์ฉ ์๋ค. ๊ฐ๊ฐ ์ ์
๋ ๊ฒฝ์ฐ์ ์๋ฅผ ๋ํ๋ฉด 2, 2, 2๊ฐ๊ฐ ๋๋ค.
์ด๋ฅผ ๊ณฑํ๊ณ ๋ชจ๋ ์์
๋ ๊ฒฝ์ฐ์ ์ 1์ ๋นผ์ฃผ๋ฉด 7์ด ๋ต์ด ๋๋ค.
๐ฉ๐ปโ๐ป Swift Code
import Foundation
func solution(_ clothes:[[String]]) -> Int {
var clothesDic: [String : [String]] = [:]
var answer = 1
for arr in clothes {
if clothesDic.keys.contains(arr[1]) {
clothesDic[arr[1]]?.append(arr[0])
} else {
clothesDic[arr[1]] = [arr[0]]
}
}
for key in clothesDic.keys {
answer *= (clothesDic[key]?.count)! + 1
}
return answer - 1
}
์ฝ๋ฉํ ์คํธ ์ฐ์ต - ์์ฅ
programmers.co.kr
BAPC 2013
Welcome! The BAPC 2013 is over. Winners of the competition were Geen Syntax, from Leiden. Second place went to geen.opdracht5 from Delft, followed by Algorithmics Anonymous in third, representing Utrecht. The best company team was Innovattic. The entire sc
2013.bapc.eu
'Algorithm' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Algorithm] ํ๋ฆฐํฐ (0) | 2021.06.21 |
---|---|
[Algorithm] ๊ธฐ๋ฅ๊ฐ๋ฐ (0) | 2021.06.21 |
[Algorithm] ๋คํธ์ํฌ (๊น์ด ์ฐ์ ํ์(DFS)) (0) | 2021.06.21 |
[Algorithm] ํ๊ฒ ๋๋ฒ (๊น์ด ์ฐ์ ํ์(DFS)) (0) | 2021.06.20 |
[Algorithm] ๋ชจ์๊ณ ์ฌ (์์ ํ์) (0) | 2021.06.20 |
- Total
- Today
- Yesterday
- Kakao
- ๊น์ด ์ฐ์ ํ์
- ์๋กํ ์คํ ๋ค์ค์ ์ฒด
- ๋ค๋ฆฌ๋ฅผ ์ง๋๋ ํธ๋ญ
- TIL
- IOS
- ๋ณ์ก
- ๋ฌ๋ ฅ
- ์ต์๊ณต๋ฐฐ์
- ternary
- UISearchController
- Baekjoon
- mysql
- java
- DFS
- ์ ํด๋ฆฌ๋ ํธ์ ๋ฒ
- BOJ
- SWIFT
- programmers
- ํ๋ก๊ทธ๋๋จธ์ค
- sql
- iTunes Search API
- compactMap
- calendar
- Git
- ์ต๋๊ณต์ฝ์
- map
- Firebase
- abs()
- Algorithm
์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |