Skip to content

Commit 9405d35

Browse files
committed
Solution as on 24-03-2022 06:50 am
1 parent 590fa40 commit 9405d35

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// 300.✅ Longest Increasing Subsequence
2+
3+
class Solution
4+
{
5+
public:
6+
int LIS(vector<int> &nums, int size)
7+
{
8+
vector<int> t(size, 1);
9+
10+
for (int i = 1; i < nums.size(); ++i)
11+
{
12+
for (int j = 0; j < i; ++j)
13+
{
14+
if (nums[i] > nums[j] && t[i] < t[j] + 1)
15+
t[i] = t[i] + 1;
16+
}
17+
}
18+
19+
return *max_element(t.begin(), t.end());
20+
}
21+
22+
int lengthOfLIS(vector<int> &nums)
23+
{
24+
25+
return LIS(nums, nums.size());
26+
}
27+
};

0 commit comments

Comments
 (0)