Untitled

mail@pastecode.io avatar
unknown
plain_text
23 days ago
410 B
0
Indexable
Never
class Solution {
public:
    bool increasingTriplet(vector<int>& arr) {
        int first=INT_MAX,second=INT_MAX;
        for(int i=0;i<arr.size();i++){
            if(arr[i]<=first) first=arr[i];
            else if(arr[i]<=second) second=arr[i];
            else return true;//if we reach this that means arr[i] is >than both first and scond and thus we have a answer
        }
        return false;
    }
};
Leave a Comment