알고리즘/코테대비 100문제
문제 29 - 땅따먹기 (동적계획법)
hoj0806
2025. 2. 21. 15:59
문제 링크 : https://school.programmers.co.kr/learn/courses/30/lessons/12913
프로그래머스
SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프
programmers.co.kr
문제
내 정답 코드
function solution(land) {
for(let i = 1; i <land.length; i++) {
for(let j = 0; j < 4; j++) {
land[i][j]+= Math.max(...land[i-1].filter((_, index) => index !== j))
}
}
return Math.max(...land[land.length - 1])
}