728x90
def solution(land):
answer = 0
for i in range(1,len(land)) :
for j in range(len(land[0])) :
land[i][j] += max(land[i-1][:j] + land[i-1][j+1:])
return max(land[len(land)-1])
풀이 및 회고
처음에는 DFS 탐색을 통해 큰 값을 return 하는 풀이 인줄 알았다... 하지만 이중 for 문을 통해 간단하게 풀 수 있었습니다.
슬라이싱을 활용해 같은 index 를 더하지 않는 방법이 있었습니다.
728x90
'프로그래머스' 카테고리의 다른 글
프로그래머스 LV 1 모의고사 (0) | 2024.06.24 |
---|---|
프로그래머스 LV 2 주식 가격 (0) | 2024.06.24 |
프로그래머스 LV 2 롤케이크 자르기 (0) | 2024.06.22 |
프로그래머스 LV 2 방문길이 (0) | 2024.06.22 |
프로그래머스 LV2 더 맵게 (0) | 2024.06.21 |