๐น ๊ฐ์ธ์ ๋ณด ์์ง ์ ํจ๊ธฐ๊ฐ
1. ๋ฌธ์ ๋งํฌ
2023 KAKAO BLIND RECRUITMENT: ๊ฐ์ธ์ ๋ณด ์์ง ์ ํจ๊ธฐ๊ฐ
2. ์ฝ๋
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
def solution(today, terms, privacies):
answer = []
dict_terms = {}
today = list(map(int, today.split('.')))
for t in terms:
term, month = t.split(' ')
dict_terms[term] = int(month)
for i in range(len(privacies)):
date, term = privacies[i].split(' ')
p_date = list(map(int, date.split('.')))
# ๋ ์ง ๊ณ์ฐ
p_date[1] += dict_terms[term]
if p_date[1] > 12:
if p_date[1] % 12 == 0:
p_date[0] += p_date[1] // 12 - 1
p_date[1] = 12
else:
p_date[0] += p_date[1] // 12
p_date[1] %= 12
# ์ ํจ๊ธฐ๊ฐ ์ง๋ฌ์ ์ ํ๊ธฐ
if min(today, p_date) == p_date:
answer.append(i+1)
return answer
์ ํ์ฑ
ํ ์คํธ 1 ใ ํต๊ณผ (0.03ms, 10.5MB) ํ ์คํธ 2 ใ ํต๊ณผ (0.05ms, 10.6MB) ํ ์คํธ 3 ใ ํต๊ณผ (0.05ms, 10.4MB) ํ ์คํธ 4 ใ ํต๊ณผ (0.04ms, 10.5MB) ํ ์คํธ 5 ใ ํต๊ณผ (0.05ms, 10.4MB) ํ ์คํธ 6 ใ ํต๊ณผ (0.06ms, 10.4MB) ํ ์คํธ 7 ใ ํต๊ณผ (0.06ms, 10.4MB) ํ ์คํธ 8 ใ ํต๊ณผ (0.06ms, 10.4MB) ํ ์คํธ 9 ใ ํต๊ณผ (0.13ms, 10.4MB) ํ ์คํธ 10 ใ ํต๊ณผ (0.13ms, 10.5MB) ํ ์คํธ 11 ใ ํต๊ณผ (0.13ms, 10.4MB) ํ ์คํธ 12 ใ ํต๊ณผ (0.24ms, 10.5MB) ํ ์คํธ 13 ใ ํต๊ณผ (0.25ms, 10.4MB) ํ ์คํธ 14 ใ ํต๊ณผ (0.13ms, 10.4MB) ํ ์คํธ 15 ใ ํต๊ณผ (0.15ms, 10.3MB) ํ ์คํธ 16 ใ ํต๊ณผ (0.24ms, 10.4MB) ํ ์คํธ 17 ใ ํต๊ณผ (0.24ms, 10.4MB) ํ ์คํธ 18 ใ ํต๊ณผ (0.25ms, 10.4MB) ํ ์คํธ 19 ใ ํต๊ณผ (0.23ms, 10.5MB) ํ ์คํธ 20 ใ ํต๊ณผ (0.25ms, 10.5MB)
3. ํด์ค
์ฝ๊ด์ ํด๋นํ๋ ์ ํจ๊ธฐ๊ฐ์ ๊ฐ์ธ์ ๋ณด ์์ง ๋ ์ง์ ๋ํด์ค ํ ์ฌ๋ฐ๋ฅธ ๋ ์ง ๊ณ์ฐ์ ํด์ค๋ค.
ex) ์ ํจ๊ธฐ๊ฐ = 100, ๊ฐ์ธ์ ๋ณด ์์ง ๋ ์ง โ2021.03.23โ โ โ2021.103.23โ โ โ2029.7.23โ
๊ทธ ํ ์ค๋ ๋ ์ง์ ํ๊ธฐ ๋ ์ง๋ฅผ ๋น๊ตํ์ฌ ํ๊ธฐ๋ ์ง๊ฐ ๋ ์์์(์ ํจ๊ธฐ๊ฐ์ด ์ง๋ฌ์ ์) answer์ ์ถ๊ฐํ๋ค.
This post is licensed under CC BY 4.0 by the author.