Skip to content

Commit

Permalink
LeetCode/300v2.cc
Browse files Browse the repository at this point in the history
  • Loading branch information
userr2232 committed May 25, 2022
1 parent 31ede21 commit 528314b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions LeetCode/300v2.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class Solution {
public:
int lengthOfLIS(vector<int>& nums) {
vector<int> L(nums.size());
int k{0};
for(auto&& num : nums) {
int pos = distance(L.begin(), lower_bound(L.begin(), next(L.begin(), k), num));
L[pos] = num;
if(pos == k) ++k;
}
return k;
}
};

0 comments on commit 528314b

Please sign in to comment.