leetcode

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

commitca5b3868b4b0e22d430c9eb49399f48f29cc486e
parent8e90c7167cf7a35b951a20f10d79758a99ea39a3
authorDimitrije Dobrota <mail@dimitrijedobrota.com>
dateThu, 12 Sep 2024 21:35:52 +0200

Daily Problem

Diffstat:
AProblems/1684.cpp|+++++++++++++++++++
MREADME.md|+

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


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

@@ -0,0 +1,19 @@

class Solution {
public:
int countConsistentStrings(const string &allowed, const vector<string> &words) const {
bool count[26] = {false};
int res = 0;
for (const char c : allowed)
count[c - 'a'] = true;
for (const auto &word : words) {
for (const char c : word) {
if (!count[c - 'a']) goto next;
}
res++;
next:;
}
return res;
}
};

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

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

| 1679 | Medium | [Max Number of K-Sum Pairs](Problems/1679.cpp) |
| 1680 | Medium | [Concatenation of Consecutive Binary Numbers](Problems/1680.cpp) |
| 1683 | Easy | [Invalid Tweets](Problems/1683.cpp) |
| 1684 | Easy | [Count the Number of Consistent Strings](Problems/1684.cpp) |
| 1685 | Medium | [Sum of Absolute Differences in a Sorted Array](Problems/1685.cpp) |
| 1686 | Medium | [Stone Game VI](Problems/1686.cpp) |
| 1688 | Easy | [Count of Matches in Tournament](Problems/1688.cpp) |