Advertisement
LikeRampage

C++ leetcode334. Increasing Triplet Subsequence chatgpt unlimited

Apr 24th, 2024
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. class Solution {
  2. public:
  3. bool increasingTriplet(vector<int>& nums) {
  4. if(nums.size() < 3) {
  5. return false;
  6. }
  7.  
  8. int first = INT_MAX;
  9. int second = INT_MAX;
  10.  
  11. for(int num : nums) {
  12. if(num <= first) {
  13. first = num;
  14. } else if(num <= second) {
  15. second = num;
  16. } else {
  17. return true;
  18. }
  19. }
  20.  
  21. return false;
  22. }
  23. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement