✨ 문제 ✨

✨ 정답 ✨
function solution(triangle){
let answer=0;
let rows=triangle.length;
let columns=triangle[rows-1].length;
let dp=Array.from({length:rows}, ()=>new Array(columns).fill(0))
dp[0][0]=triangle[0][0];
for (let i=1;i<rows;i++){
for (let j=0;j<triangle[i].length;j++){
if (dp[i-1][j-1]&& dp[i-1][j]){
dp[i][j]=Math.max(dp[i-1][j-1]+triangle[i][j], dp[i-1][j]+triangle[i][j])
}else if (dp[i-1][j-1]){
dp[i][j]=dp[i-1][j-1]+triangle[i][j];
}else if (dp[i-1][j]){
dp[i][j]=dp[i-1][j]+triangle[i][j];
}
}
}
answer=Math.max(...dp[rows-1])
return answer;
}
🧵 참고한 정답지 🧵
💡💡 기억해야 할 점 💡💡