similar solution to LIS


  • 0
    T
    class Solution {
    public:
        bool increasingTriplet(vector<int>& nums) {
            vector<int> triple;
            for (int i:nums) {
                auto iter = lower_bound(triple.begin(), triple.end(), i);
                if (iter == triple.end()) {
                    triple.push_back(i);
                } else *iter = i;
                if (triple.size() >= 3) return true;
            }
            return false;
        }
    };
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.