leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

0334.cpp (328B)


      1 class Solution {
      2   public:
      3     bool increasingTriplet(vector<int> &nums) {
      4         int a = INT_MAX, b = INT_MAX;
      5         for (int x : nums) {
      6             if (x <= a)
      7                 a = x;
      8             else if (x <= b)
      9                 b = x;
     10             else
     11                 return true;
     12         }
     13         return false;
     14     }
     15 };