Skip to content

Commit

Permalink
Solve: Increasing Triplet Subsequence
Browse files Browse the repository at this point in the history
  • Loading branch information
fkdl0048 committed Oct 12, 2024
1 parent 93685fd commit 6b96c78
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions LeetCode/Increasing Triplet Subsequence.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class Solution {
public:
bool increasingTriplet(vector<int>& nums) {
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;
}
};

0 comments on commit 6b96c78

Please sign in to comment.