leetcodeSolution to some Leetcode problems written in C++ |
git clone git://git.dimitrijedobrota.com/leetcode.git |
Log | Files | Refs | README | LICENSE |
0779.cpp (244B)
0 class Solution {
1 public:
2 constexpr int kthGrammar(const int n, const int k) const {
3 if (n == 1) return 0;
4 const int mid = 1 << (n - 2);
5 return k > mid ? !kthGrammar(n - 1, k - mid) : kthGrammar(n - 1, k);
6 }
7 };