File tree 2 files changed +38
-0
lines changed
Coding-Interviews/047/cpp-047
2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change
1
+ cmake_minimum_required (VERSION 3.24)
2
+ project (cpp_047)
3
+
4
+ set (CMAKE_CXX_STANDARD 17)
5
+
6
+ add_executable (cpp_047 main.cpp)
Original file line number Diff line number Diff line change
1
+ // / Source : https://leetcode.cn/problems/li-wu-de-zui-da-jie-zhi-lcof/
2
+ // / Author : liuyubobobo
3
+ // / Time : 2023-03-07
4
+
5
+ #include < iostream>
6
+ #include < vector>
7
+
8
+ using namespace std ;
9
+
10
+
11
+ // / DP
12
+ // / Time Complexity: O(R * C)
13
+ // / Space Complexity: O(R * C)
14
+ class Solution {
15
+ public:
16
+ int maxValue (vector<vector<int >>& grid) {
17
+
18
+ int R = grid.size (), C = grid[0 ].size ();
19
+
20
+ vector<vector<int >> dp (R + 1 , vector<int >(C + 1 , 0 ));
21
+ for (int i = 0 ; i < R; i ++)
22
+ for (int j = 0 ; j < C; j ++)
23
+ dp[i + 1 ][j + 1 ] = max (dp[i][j + 1 ], dp[i + 1 ][j]) + grid[i][j];
24
+ return dp[R][C];
25
+ }
26
+ };
27
+
28
+
29
+ int main () {
30
+
31
+ return 0 ;
32
+ }
You can’t perform that action at this time.
0 commit comments