diff options
author | Jack Sangdahl <[email protected]> | 2025-06-27 12:23:02 -0600 |
---|---|---|
committer | Jack Sangdahl <[email protected]> | 2025-06-27 12:23:02 -0600 |
commit | a96b65cbfad7f62f3db6b2eab105e4e25c0414c5 (patch) | |
tree | e2a2b3f49f9fb741be81415266ac93e74cff42ec /other/min_path_sum.cpp | |
parent | 694ad5ed71edcb1deccab54b72d706b779918276 (diff) | |
download | leetcode-a96b65cbfad7f62f3db6b2eab105e4e25c0414c5.tar.gz leetcode-a96b65cbfad7f62f3db6b2eab105e4e25c0414c5.zip |
chore: remove old cpp and rust solutions
Diffstat (limited to 'other/min_path_sum.cpp')
-rw-r--r-- | other/min_path_sum.cpp | 29 |
1 files changed, 0 insertions, 29 deletions
diff --git a/other/min_path_sum.cpp b/other/min_path_sum.cpp deleted file mode 100644 index 46c2ff1..0000000 --- a/other/min_path_sum.cpp +++ /dev/null @@ -1,29 +0,0 @@ -// 64. Minimum Path Sum -#include "leetcode.h" - -// given 'm x n grid' filled with non-negative numbers, find a path from top -// left to bottom right, which minimises the sum of all numbers along its path - -class Solution { -public: - int minPathSum(vvd & grid) { - int m = grid.size(), n = grid[0].size(); - vvd sum(m, vector<int>(n, grid[0][0])); - for (int i = 1; i < m; i++) - sum[i][0] = sum[i - 1][0] + grid[i][0]; - for (int j = 1; j < n; j++) - sum[0][j] = sum[0][j - 1] + grid[0][j]; - for (int i = 1; i < m; i++) - for (int j = 1; j < n; j++) - sum[i][j] = min(sum[i - 1][j], sum[i][j - 1]) + grid[i][j]; - return sum[m - 1][n - 1]; - } -}; - -int main() { - Solution obj; - vvd g1 = {{1, 3, 1}, {1, 5, 1}, {4, 2, 1}}; - vvd g2 = {{1, 2, 3}, {4, 5, 6}}; - printf("%d\n", obj.minPathSum(g1)); // expect: 7 - printf("%d\n", obj.minPathSum(g2)); // expect: 12 -} |