Find the minimal path sum from the top left to the bottom right of a 2D grid by only moving right or down.
Given a 2D square grid of positive integers, write a function to find the minimal sum of a path from the top left corner to the bottom right corner. You can only move to the right or down. Input will be a 2D array of integers, and output should be the minimal sum.
For instance, given the following grid:
[
[1, 3, 4],
[1, 5, 2],
[4, 4, 1],
]
The minimal path sum is 10 (1 -> 1 -> 5 -> 2 -> 1).
# | Size | % | Users |
---|---|---|---|
#1 | 53 c. | Top 7% | |
#2 | 82 c. | Top 14% | |
#3 | 86 c. | Top 29% | |
#4 | 114 c. | Top 36% | |
#5 | 115 c. | Top 43% | |
#6 | 131 c. | Top 50% | |
#7 | 132 c. | Top 57% | |
#8 | 168 c. | Top 64% | |
#9 | 175 c. | Top 71% | |
#10 | 209 c. | Top 86% | |
#11 | 252 c. | Top 93% | |
#12 | 276 c. | Top 100% |