题目
题解
- 不一定连续
- 二指针贪心算法
设立small ,mid 指针
代码
class Solution {
public:
bool increasingTriplet(vector<int>& nums) {
int n = nums.size();
if(n<3) return false;
int small = INT_MAX, mid = INT_MAX;
for (auto num : nums) {
if (num <= small)
small = num;
else if (num <= mid)
mid = num;
else if (num > mid)
return true;
}
return false;
}
};