题目:
解答:
1 class Solution { 2 public: 3 bool increasingTriplet(vector<int>& nums) 4 { 5 int len = nums.size(); 6 7 if (len < 3) 8 { 9 return false; 10 } 11 12 int small = INT_MAX; 13 int mid = INT_MAX; 14 15 for (auto num : nums) 16 { 17 if (num <= small) 18 { 19 small = num; 20 } else if (num <= mid) 21 { 22 mid = num; 23 } 24 else if (num > mid) 25 { 26 return true; 27 } 28 } 29 return false; 30 31 } 32 };