leetcode

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

1550.cpp (302B)


      1 class Solution {
      2   public:
      3     bool threeConsecutiveOdds(const vector<int> &arr) const {
      4         int cnt = 0;
      5 
      6         for (const int n : arr) {
      7             if (n % 2 == 0)
      8                 cnt = 0;
      9             else if (++cnt == 3)
     10                 return true;
     11         }
     12 
     13         return false;
     14     }
     15 };