334 Increasing Triplet Subsequence
Given [1, 2, 3, 4, 5],
return true.
Given [5, 4, 3, 2, 1],
return false.bool increasingTriplet(vector<int>& nums) {
int one = INT_MAX, two = INT_MAX;
for (int i : nums) { // sequential search ensures that index(one) < index(two) ...
if (i <= one) one = i; // the smallest since first if statement
else if (i <= two) two = i; // second smallest
else return true; // finish
}
return false;
}Last updated