Clean and short C++ solution


  • 0
    D
    class Solution {
    public:
        bool increasingTriplet(vector<int>& nums) {
            int N = nums.size();
            if(N < 3){
                return false;
            }
            int a = INT_MAX, b = INT_MAX;
            for(int i = 0; i < N; i++){
                if(b < nums[i] ){
                    return true;
                }
                else if(a < nums[i]){
                    b = nums[i];
                }
                else{
                    a = nums[i];
                }
            }
            return false;;
        }
    };
    

Log in to reply
 

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