Skip to content

Commit dc15a6c

Browse files
authored
Create Solution.cpp
base solution
1 parent 4974ed3 commit dc15a6c

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Solution {
2+
public:
3+
int lengthOfLIS(vector<int>& nums) {
4+
if (nums.size() == 0)
5+
return 0 ;
6+
int M[nums.size()] = {0, } ;
7+
int MM = -1 ;
8+
for (int i = nums.size()-1; i >= 0; --i)
9+
{
10+
for (int j = i+1; j < nums.size(); ++j)
11+
if (nums[i] < nums[j])
12+
M[i] = max(M[i], M[j]) ;
13+
MM = max(++M[i], MM) ;
14+
}
15+
return MM ;
16+
}
17+
};

0 commit comments

Comments
 (0)