[프로그래머스] 덧칠하기
반복문 for 사용
section[i]에서 - paint 값이 m보다 크다면
answer +=1
파이썬
def solution(n, m, section):
answer = 1
paint = section[0]
for i in range(1, len(section)):
if section[i] - paint >= m:
answer += 1
paint = section[i]
return answer
댓글남기기