leetcode

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

commit 20cef8f82d148684351d796af7fd5b21b1c41a7e
parent 3b519d6d4e2182308fb49b25f925dfd1311e7dcf
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date:   Mon,  1 Jul 2024 12:08:55 +0200

Daily Problem

Diffstat:
AProblems/1550.cpp | 15+++++++++++++++
MREADME.md | 1+
2 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/Problems/1550.cpp b/Problems/1550.cpp @@ -0,0 +1,15 @@ +class Solution { + public: + bool threeConsecutiveOdds(const vector<int> &arr) const { + int cnt = 0; + + for (const int n : arr) { + if (n % 2 == 0) + cnt = 0; + else if (++cnt == 3) + return true; + } + + return false; + } +}; diff --git a/README.md b/README.md @@ -871,6 +871,7 @@ for solving problems. | 1544 | Easy | [Make The String Great](Problems/1544.cpp) | | 1545 | Medium | [Find Kth Bit in Nth Binary String](Problems/1545.cpp) | | 1547 | Hard | [Minimum Cost to Cut a Stick](Problems/1547.cpp) | +| 1550 | Easy | [Three Consecutive Odds](Problems/1550.cpp) | | 1551 | Medium | [Minimum Operations to Make Array Equal](Problems/1551.cpp) | | 1552 | Medium | [Magnetic Force Between Two Balls](Problems/1552.cpp) | | 1557 | Medium | [Minimum Number of Vertices to Reach All Nodes](Problems/1557.cpp) |