leetcode

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

0779.cpp (244B)


      1 class Solution {
      2   public:
      3     constexpr int kthGrammar(const int n, const int k) const {
      4         if (n == 1) return 0;
      5         const int mid = 1 << (n - 2);
      6         return k > mid ? !kthGrammar(n - 1, k - mid) : kthGrammar(n - 1, k);
      7     }
      8 };