leetcode334 递增的三元子序列

 

 

 

class Solution {
public:
    bool increasingTriplet(vector<int>& nums) {
        //使用双指针;
        int len=nums.size();
        if(len<2) return false;
        int first=INT_MAX,second=INT_MAX;
        for(auto n: nums){
            if(n<=first)
                first=n;
            else if(n<=second)
                second=n;
            else
                return true;
        }
        return false;
    }
};

 

posted @ 2019-11-20 11:58  Joel_Wang  阅读(150)  评论(0编辑  收藏  举报