leetcode

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

commit d48b92e41033d5976a9796f48c6fad6292409336
parent dc9c4c4049c56d0b70902ccb9bdde3c32f217a79
author Dimitrije Dobrota < mail@dimitrijedobrota.com >
date Wed, 3 Jul 2024 10:21:15 +0200

1 Random Problem

Diffstat:
A Problems/2588.cpp | +++++++++++++++++
M README.md | +

2 files changed, 18 insertions(+), 0 deletions(-)


diff --git a/ Problems/2588.cpp b/ Problems/2588.cpp

@@ -0,0 +1,17 @@

class Solution {
public:
long long beautifulSubarrays(const vector<int> &nums) const {
static int count[1048577];
long long res = 0;
int crnt = 0;

memset(count, 0x00, sizeof(count));
count[0] = 1;
for (const int n : nums) {
crnt ^= n;
res += count[crnt]++;
}

return res;
}
};

diff --git a/ README.md b/ README.md

@@ -1190,6 +1190,7 @@ for solving problems.

| 2568 | Medium | [Minimum Impossible OR](Problems/2568.cpp) |
| 2571 | Medium | [Minimum Operations to Reduce an Integer to 0](Problems/2571.cpp) |
| 2579 | Medium | [Count Total Number of Colored Cells](Problems/2579.cpp) |
| 2588 | Medium | [Count the Number of Beautiful Subarrays](Problems/2588.cpp) |
| 2592 | Medium | [Maximize Greatness of an Array](Problems/2592.cpp) |
| 2593 | Medium | [Find Score of an Array After Marking All Elements](Problems/2593.cpp) |
| 2596 | Medium | [Check Knight Tour Configuration](Problems/2596.cpp) |