Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit dc15a6c

Browse files
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
Lines changed: 17 additions & 0 deletions
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)

AltStyle によって変換されたページ (->オリジナル) /