Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- bool increasingTriplet(vector<int>& nums) {
- if(nums.size() < 3) {
- return false;
- }
- int first = INT_MAX;
- int second = INT_MAX;
- for(int num : nums) {
- if(num <= first) {
- first = num;
- } else if(num <= second) {
- second = num;
- } else {
- return true;
- }
- }
- return false;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement