leetcode

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

commit 7c3f421e392337f4c3c58e8778526574c23fb532
parent 55f537f6393e910be3212e4812560fcd072cd6f3
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date:   Mon, 26 Feb 2024 15:15:33 +0000

1 Random Problem

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

diff --git a/Problems/1764.cpp b/Problems/1764.cpp @@ -0,0 +1,15 @@ +class Solution { + public: + bool canChoose(const vector<vector<int>> &groups, const vector<int> &nums) const { + const int n = size(groups); + int group = 0, crnt = 0, start = 0; + for (int i = 0; i < size(nums) && group < n; i++) { + if (nums[i] != groups[group][crnt]) + crnt = 0, i = start, start++; + else if (++crnt == size(groups[group])) + group++, crnt = 0, start = i; + } + + return group == n; + } +}; diff --git a/README.md b/README.md @@ -890,6 +890,7 @@ for solving problems. | 1758 | Easy | [Minimum Changes To Make Alternating Binary String](Problems/1758.cpp) | | 1759 | Medium | [Count Number of Homogenous Substrings](Problems/1759.cpp) | | 1760 | Medium | [Minimum Limit of Balls in a Bag](Problems/1760.cpp) | +| 1764 | Medium | [Form Array by Concatenating Subarrays of Another Array](Problems/1764.cpp) | | 1765 | Medium | [Map of Highest Peak](Problems/1765.cpp) | | 1768 | Easy | [Merge Strings Alternately](Problems/1768.cpp) | | 1769 | Medium | [Minimum Number of Operations to Move All Balls to Each Box](Problems/1769.cpp) |