Leetcode 334 Solution
This article provides solution to leetcode question 334 (increasing-triplet-subsequence)
Access this page by simply typing in "lcs 334" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/increasing-triplet-subsequence
Solution
class Solution {
public:
bool increasingTriplet(vector<int>& nums) {
set<int> s;
for (auto num : nums)
{
auto it = s.lower_bound(num);
if (it != s.end())
s.erase(it);
s.insert(num);
if (s.size() >= 3)
return true;
}
return false;
}
};