leetcodeSolution to some Leetcode problems written in C++ |
git clone git://git.dimitrijedobrota.com/leetcode.git |
Log | Files | Refs | README | LICENSE | |
commit | fe2481131cfc2635ad0691aa7eb45423f89b979c |
parent | 25b4aa57228ad8118fb819c1c46f68a957817b6f |
author | Dimitrije Dobrota <mail@dimitrijedobrota.com> |
date | Wed, 25 Oct 2023 23:33:25 +0000 |
Daily Problem
Diffstat:A | Problems/0779.cpp | | | ++++++++ |
M | README.md | | | + |
2 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/Problems/0779.cpp b/Problems/0779.cpp
@@ -0,0 +1,8 @@
class Solution {
public:
constexpr int kthGrammar(const int n, const int k) const {
if (n == 1) return 0;
const int mid = 1 << (n - 2);
return k > mid ? !kthGrammar(n - 1, k - mid) : kthGrammar(n - 1, k);
}
};
diff --git a/README.md b/README.md
@@ -396,6 +396,7 @@ for solving problems.
| 0752 | Medium | [Open the Lock](Problems/0752.cpp) |
| 0763 | Medium | [Partition Labels](Problems/0763.cpp) |
| 0767 | Medium | [Reorganize String](Problems/0767.cpp) |
| 0779 | Medium | [K-th Symbol in Grammar](Problems/0779.cpp) |
| 0783 | Easy | [Minimum Distance Between BST Nodes](Problems/0783.cpp) |
| 0784 | Medium | [Letter Case Permutation](Problems/0784.cpp) |
| 0785 | Medium | [Is Graph Bipartite?](Problems/0785.cpp) |