Solution
bool IncresingTripletSubsequence (vector<int> &nums) {
int a = INT_MAX;
int b = INT_MAX;
for (int num : nums) {
if (num <= a) {
a = num;
} else if (num <= b) {
b = num;
} else {
return true;
}
}
return false;
}
Complexity
Runtime: O(n)
Space: O(1)
Top comments (0)