Post

๐Ÿน ๊ฐœ์ธ์ •๋ณด ์ˆ˜์ง‘ ์œ ํšจ๊ธฐ๊ฐ„

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.