Written by
최태열
on
on
[Python][프로그래머스][Level4] 스티커 모으기(2)
[Python][프로그래머스][Level4] 스티커 모으기(2)
코드
def solution(sticker):
if len(sticker)<=3:
return max(sticker)
answer=0
dp=[i for i in sticker]
dp[1]=0
dp[2]+=sticker[0]
for idx in range(3,len(sticker)-1):
dp[idx]+=max(dp[idx-2],dp[idx-3])
answer=max(dp)
dp=[i for i in sticker]
dp[0]=0
for idx in range(3,len(sticker)):
dp[idx]=sticker[idx]+max(dp[idx-2],dp[idx-3])
return max(answer,max(dp))
Discussion and feedback