Title: #120 - Triangle - LeetCode JavaScript Solutions
Open Graph Title: #120 - Triangle - LeetCode JavaScript Solutions
X Title: #120 - Triangle - LeetCode JavaScript Solutions
Description: Given a triangle array, return the minimum path sum from top to bottom. For each step, you may move to an adjacent number of the row below. ...
Open Graph Description: Given a triangle array, return the minimum path sum from top to bottom. For each step, you may move to an adjacent number of the row below. ...
X Description: Given a triangle array, return the minimum path sum from top to bottom. For each step, you may move to an adjacent number of the row below. ...
Keywords:
Opengraph URL: https://leetcodejavascript.com/solutions/triangle
Domain: leetcodejavascript.com
{"@context":"https://schema.org","@type":"Code","url":"https://leetcodejavascript.com/solutions/triangle","name":"#120 - Triangle - LeetCode JavaScript Solutions","description":"Given a triangle array, return the minimum path sum from top to bottom. For each step, you may move to an adjacent number of the row below. ...","programmingLanguage":"JavaScript","codeRepository":"https://github.com/JoshCrozier/leetcode-javascript","codeSampleType":"JavaScript","text":"/**\n * @param {number[][]} triangle\n * @return {number}\n */\nvar minimumTotal = function(triangle) {\n for (let i = triangle.length - 2; i > -1; i--) {\n for (let j = 0; j < triangle[i].length; j++) {\n triangle[i][j] += Math.min( triangle[i + 1][j], triangle[i + 1][j + 1]);\n }\n }\n\n return triangle[0][0];\n};","keywords":"LeetCode 120, #120 - Triangle, Medium, JavaScript solution","learningResourceType":"Code","isAccessibleForFree":true,"educationalLevel":"intermediate","interactivityType":"mixed"}
| author | LeetCodeJavascript.com |
| og:type | article |
| og:image | https://leetcodejavascript.com/og-image.jpg |
| og:site_name | LeetCode JavaScript Solutions |
| twitter:card | summary_large_image |
| twitter:url | https://leetcodejavascript.com/solutions/triangle |
| twitter:image | https://leetcodejavascript.com/og-image.jpg |
| twitter:creator | @joshcrozier |
| theme-color | #1f2937 |
Links:
| LeetCodeJavascript.com | https://leetcodejavascript.com/ |
| Star on GitHub | https://github.com/JoshCrozier/leetcode-javascript |
| Back to all solutions | https://leetcodejavascript.com |
| View on LeetCode | https://leetcode.com/problems/triangle/ |
| View on GitHub | https://github.com/JoshCrozier/leetcode-javascript/blob/master/solutions/0120-triangle.js |
| Array | https://leetcodejavascript.com/tags/array |
| Dynamic Programming | https://leetcodejavascript.com/tags/dynamic-programming |
| Josh Crozier | https://joshcrozier.com |
Viewport: width=device-width, initial-scale=1.0
Robots: index, follow