Post

Programmers. Painting

덧칠하기

  • practice problem
  • 정답률: 59%
  • 2023.07.21
  • 15:00 ~ 15:05 (5 min)
  • 후기: len check을 통해 cnt를 써서 쉽게 문제를 해결.

Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
def solution(n, m, section):
    answer = 0
    len_check = 0
    cnt = 0
    
    for idx, i in enumerate(section):
        if idx == 0:
            len_check = i+m-0.5
            cnt += 1
            continue
        else:
            if i > len_check:
                len_check = i+m-0.5
                cnt += 1
    return cnt
This post is licensed under CC BY 4.0 by the author.