leetcode

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

commit 32a99662b8545cfd76633955ff0758692a8575a4
parent 92feeaa0bbc3c064f641eeb5c4405c23196b7108
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date:   Sat, 23 Nov 2024 17:07:25 +0100

1 Random Problem

Diffstat:
AProblems/0717.cpp | 12++++++++++++
MREADME.md | 1+
2 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/Problems/0717.cpp b/Problems/0717.cpp @@ -0,0 +1,12 @@ +class Solution { + public: + bool isOneBitCharacter(const vector<int> &bits) const { + int last = -2; + + for (int i = 0; i < size(bits); i++) { + if (bits[i]) last = i++; + } + + return last != size(bits) - 2; + } +}; diff --git a/README.md b/README.md @@ -546,6 +546,7 @@ reference and a base for solving problems. | 0713 | Medium | [Subarray Product Less Than K](Problems/0713.cpp) | | 0714 | Medium | [Best Time to Buy and Sell Stock with Transaction Fee](Problems/0714.cpp) | | 0715 | Hard | [Range Module](Problems/0715.cpp) | +| 0717 | Easy | [1-bit and 2-bit Characters](Problems/0717.cpp) | | 0718 | Medium | [Maximum Length of Repeated Subarray](Problems/0718.cpp) | | 0719 | Hard | [Find K-th Smallest Pair Distance](Problems/0719.cpp) | | 0720 | Medium | [Longest Word in Dictionary](Problems/0720.cpp) |