0
点赞
收藏
分享

微信扫一扫

数字化人才稀缺考取CDGA更具竞争力!

春意暖洋洋 2024-08-14 阅读 6

题目:

题解:

class Solution {
public:
    bool increasingTriplet(vector<int>& nums) {
        int n = nums.size();
        if (n < 3) {
            return false;
        }
        int first = nums[0], second = INT_MAX;
        for (int i = 1; i < n; i++) {
            int num = nums[i];
            if (num > second) {
                return true;
            } else if (num > first) {
                second = num;
            } else {
                first = num;
            }
        }
        return false;
    }
};
举报

相关推荐

0 条评论