🟡 剑指 Offer II 100. 三角形中最小路径之和
LeetCode 提示
题目难度 中等
原题链接 🔗 leetcode
#
题解1class Solution { public int minimumTotal(List<List<Integer>> triangle) { List<Integer> steps = new ArrayList<>(triangle.get(triangle.size()-1)); for (int lvl = triangle.size()-2; lvl >= 0; lvl -= 1) { for (int node = 0; node < triangle.get(lvl).size(); node += 1) { var newMin = triangle.get(lvl).get(node) + Math.min( steps.get(node), steps.get(node+1) ); steps.set(node, newMin); } } return steps.get(0); }}