leetcode

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

commit 52df518d7bee5c4a6945fb828eae99ced27a7a75
parent 73f0ace490b32599c2f8737e9ff2fc0a28eb4054
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date:   Mon,  9 Dec 2024 18:03:57 +0100

Daily Problem

Diffstat:
AProblems/3152.cpp | 17+++++++++++++++++
MREADME.md | 1+
2 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/Problems/3152.cpp b/Problems/3152.cpp @@ -0,0 +1,17 @@ +class Solution { + public: + vector<bool> isArraySpecial(const vector<int> &nums, const vector<vector<int>> &queries) const { + static int vec[100001]; + + for (int i = 1; i < size(nums); i++) { + vec[i] = vec[i - 1] + (nums[i - 1] % 2 == nums[i] % 2); + } + + vector<bool> res; + for (const auto &query : queries) { + res.push_back(vec[query[0]] == vec[query[1]]); + } + + return res; + } +}; diff --git a/README.md b/README.md @@ -1462,6 +1462,7 @@ reference and a base for solving problems. | 3111 | Medium | [Minimum Rectangles to Cover Points](Problems/3111.cpp) | | 3133 | Medium | [Minimum Array End](Problems/3133.cpp) | | 3137 | Medium | [Minimum Number of Operations to Make Word K-Periodic](Problems/3137.cpp) | +| 3152 | Medium | [Special Array II](Problems/3152.cpp) | | 3159 | Medium | [Find Occurrences of an Element in an Array](Problems/3159.cpp) | | 3163 | Medium | [String Compression III](Problems/3163.cpp) | | 3190 | Easy | [Find Minimum Operations to Make All Elements Divisible by Three](Problems/3190.cpp) |