[문제 풀이]

  • m 길이의 롤러로 페인트를 칠하기 때문에 (현재 벽을 칠하는 칸 + m - 1)칸 까지 벽이 칠해지게 됩니다.
  • 칠해야하는 제일 앞 칸 벽부터 칠하면서 함께 칠해진 벽을 같이 section에서 제외되도록 코드를 구성했습니다.

 

[문제 코드]

from collections import deque
def solution(n, m, section):
    answer = 0
    s = deque(section)
    while s:
        val = s[0]
        while s and val <= s[0] <= val + m-1:
            s.popleft()
        answer += 1
    return answer

+ Recent posts