Posted on

Description

Submission

class Solution {
public:
bool increasingTriplet(vector<int>& nums) {
vector<int> stk;
for(int x: nums) {
if(stk.empty()) {
stk.push_back(x);
continue;
}
auto iter = lower_bound(stk.begin(), stk.end(), x);
if(iter == stk.end()) {
stk.push_back(x);
} else {
*iter = x;
}
if(stk.size() >= 3) return true;
}
return false;
}
};
class Solution { public: bool increasingTriplet(vector<int>& nums) { vector<int> stk; for(int x: nums) { if(stk.empty()) { stk.push_back(x); continue; } auto iter = lower_bound(stk.begin(), stk.end(), x); if(iter == stk.end()) { stk.push_back(x); } else { *iter = x; } if(stk.size() >= 3) return true; } return false; } };
class Solution {
public:
    bool increasingTriplet(vector<int>& nums) {
        vector<int> stk;

        for(int x: nums) {
            if(stk.empty()) {
                stk.push_back(x);
                continue;
            }
            auto iter = lower_bound(stk.begin(), stk.end(), x);
            if(iter == stk.end()) {
                stk.push_back(x);
            } else {
                *iter = x;
            }
            if(stk.size() >= 3) return true;
        }

        return false;
    }
};

Leave a Reply

Your email address will not be published. Required fields are marked *