Sharing a simple C solution, only 4 ms


  • 9
    W

    bool increasingTriplet(int* nums, int numsSize) {

    if (numsSize < 3) return false;
    int l = nums[0], m = 0x7fffffff;
    for (int i = 1; i < numsSize; i++) {
        int a = nums[i];
        if (a <= l) l = a;
        else if (a < m) m = a;
        else if (a > m) return true;
    }
    return false;
    

    }


Log in to reply
 

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