leetcode

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

0672.cpp (293B)


      1 class Solution {
      2   public:
      3     int flipLights(const int n, const int presses) const {
      4         if (n == 0 || presses == 0) return 1;
      5         if (n == 1) return 2;
      6         if (n == 2) return presses == 1 ? 3 : 4;
      7         if (presses == 1) return 4;
      8         return presses == 2 ? 7 : 8;
      9     }
     10 };