LeetCode 30 day Challenge | Day 18 | Minimum Path Sum (C++, Java, Python) | LeetCode 64

preview_player
Показать описание

**** Best Books For Data Structures & Algorithms for Interviews:**********
*****************************************************************************

LeetCode 30 day Challenge | Problem 18 | Minimum Path Sum | 18 April
LeetCode #64
Facebook Coding Interview question,
google coding interview question,
leetcode,
minimum path sum,

#Amazon #Facebook #CodingInterview #LeetCode #30DayChallenge #Google #MinimumPathSum #ShortestPath
Рекомендации по теме
Комментарии
Автор

Please share your solution, what worked for you.. Thanks.

KnowledgeCenter
Автор

I will always support your content...Great work.

williamwambua
Автор

class Solution {
public:
int grid) {
std::vector<std::vector<int>> minPath (grid.size(), std::vector<int> (grid[0].size(), 0));
minPath[0][0] = grid[0][0];
for (int i = 1; i < grid[0].size(); i++) minPath[0][i] = minPath[0][i-1] + grid[0][i];
for (int i = 1; i < grid.size(); i++) minPath[i][0] = minPath[i-1][0] + grid[i][0];
for (int i = 1; i < grid.size(); i++) {
for (int j = 1; j < grid[0].size(); j++) {
minPath[i][j] = std::min(minPath[i-1][j], minPath[i][j-1]) + grid[i][j];
}
}
return minPath[grid.size() - 1][grid[0].size() - 1];
}
};

raviashwin
Автор

You are doing great work sir keep it up!!!
thank you

ketanchauhan
Автор

Just one questn.... How can you modify this sol if they've asked to return the min path itself and not the min value..

adarshmv
visit shbcf.ru