Untitled
unknown
plain_text
2 years ago
410 B
7
Indexable
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;
}
};Editor is loading...
Leave a Comment