정수삼각형 - python(programmers)

참치돌고래·2021년 5월 18일
0

알고리즘

목록 보기
8/36
post-custom-banner

DP level3

정수삼각형

-->https://programmers.co.kr/learn/courses/30/lessons/43105

import copy

def solution(triangle):
    
    answer = 0
    
    copy1 = copy.deepcopy(triangle)
    print(id(copy1[0]))
    print(id(triangle[0]))
    for i in range(1,len(triangle)):
        for j in range(len(triangle[i-1])):
            if triangle[i][j] < triangle[i-1][j] + copy1[i][j]:  
                triangle[i][j] = triangle[i-1][j] + copy1[i][j]  
            triangle[i][j+1] = triangle[i-1][j] + copy1[i][j+1]
            
                
    answer = max(triangle[len(triangle)-1])
    return answer
profile
안녕하세요
post-custom-banner

0개의 댓글