반응형
def solution(ingredient):
count = 0
stack_arr = []
for data in ingredient:
if int(data) == 1 and stack_arr[-3:] == [1,2,3]:
stack_arr.pop()
stack_arr.pop()
stack_arr.pop()
count += 1
else:
stack_arr.append(data)
return count반응형
'삽집하는 개발들 > 알고리즘' 카테고리의 다른 글
| [14일차][프로그래머스][155652]둘만의 암호 (0) | 2023.06.27 |
|---|---|
| [13일차][프로그래머스][2021 카카오 - 72410]신규 아이디 추천 (0) | 2023.06.26 |
| [11일차][프로그래머스][2022 카카오 - 118666]성격유형 검사하기 (0) | 2023.06.21 |
| [10일차][프로그래머스][161990]바탕화면 정리 (0) | 2023.06.20 |
| [9일차][프로그래머스][2023 카카오 - 150370]개인정보 수집 유효성 검사 (0) | 2023.06.19 |