We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c1ff483 commit 695d3b5Copy full SHA for 695d3b5
Solution/Day-122.cpp
@@ -0,0 +1,16 @@
1
+int solve(vector<vector<int>>& matrix) {
2
+ for(int i=0; i<matrix.size(); ++i) {
3
+ for(int j=0; j<matrix[0].size(); ++j) {
4
+ if (i==0 && j ==0) {
5
+ continue;
6
+ } else if (i ==0) {
7
+ matrix[i][j] += matrix[i][j-1];
8
+ } else if (j==0) {
9
+ matrix[i][j] += matrix[i-1][j];
10
+ } else {
11
+ matrix[i][j] += max(matrix[i][j-1] , matrix[i-1][j]);
12
+ }
13
14
15
+ return matrix[matrix.size()-1][matrix[0].size()-1];
16
+}
0 commit comments