leetcodeSolution to some Leetcode problems written in C++ |
git clone git://git.dimitrijedobrota.com/leetcode.git |
Log | Files | Refs | README | LICENSE | |
commit | 5ccf2f8a3aa3207556aeaee792e774498fe98d1f |
parent | eed45a8b7b9e5662b7a144ac383df751b3139fc0 |
author | Dimitrije Dobrota <mail@dimitrijedobrota.com> |
date | Tue, 30 Apr 2024 18:21:04 +0200 |
Daily Problem
Diffstat:A | Problems/1915.cpp | | | ++++++++++++++++++++++++++ |
M | README.md | | | + |
2 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/Problems/1915.cpp b/Problems/1915.cpp
@@ -0,0 +1,26 @@
class Solution {
public:
long long wonderfulSubstrings(const string &word) const {
long long count[1 << 11] = {1}, res = 0;
uint16_t crnt = 0;
for (int i = 0; i < size(word); i++) {
crnt ^= 1 << (word[i] - 'a');
res += count[crnt];
for (int j = 0; j < 10; j++) {
res += count[crnt ^ (1 << j)];
}
count[crnt]++;
}
return res;
}
};
diff --git a/README.md b/README.md
@@ -976,6 +976,7 @@ for solving problems.
| 1910 | Medium | [Remove All Occurrences of a Substring](Problems/1910.cpp) |
| 1911 | Medium | [Maximum Alternating Subsequence Sum](Problems/1911.cpp) |
| 1913 | Easy | [Maximum Product Difference Between Two Pairs](Problems/1913.cpp) |
| 1915 | Medium | [Number of Wonderful Substrings](Problems/1915.cpp) |
| 1921 | Medium | [Eliminate Maximum Number of Monsters](Problems/1921.cpp) |
| 1926 | Medium | [Nearest Exit from Entrance in Maze](Problems/1926.cpp) |
| 1930 | Medium | [Unique Length-3 Palindromic Subsequences](Problems/1930.cpp) |