leetcode

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

commit 7829de912d4fb6170e53730d4af7882a4c6af3c7
parent 5ef0b5615669fec24b4fac4ef6863f9d2b23e9f9
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date:   Sat, 30 Dec 2023 19:04:00 +0000

Daily Problem

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

diff --git a/Problems/1897.cpp b/Problems/1897.cpp @@ -0,0 +1,14 @@ +class Solution { + public: + bool makeEqual(const vector<string> &words) const { + int count[27] = {0}; + for (const string &word : words) { + for (const char c : word) + count[c & 0x1F]++; + } + for (int i = 1; i <= 26; i++) { + if (count[i] % words.size()) return false; + } + return true; + } +}; diff --git a/README.md b/README.md @@ -861,6 +861,7 @@ for solving problems. | 1884 | Medium | [Egg Drop With 2 Eggs and N Floors](Problems/1884.cpp) | | 1887 | Medium | [Reduction Operations to Make the Array Elements Equal](Problems/1887.cpp) | | 1890 | Easy | [The Latest Login in 2020](Problems/1890.cpp) | +| 1897 | Easy | [Redistribute Characters to Make All Strings Equal](Problems/1897.cpp) | | 1899 | Medium | [Merge Triplets to Form Target Triplet](Problems/1899.cpp) | | 1903 | Easy | [Largest Odd Number in String](Problems/1903.cpp) | | 1905 | Medium | [Count Sub Islands](Problems/1905.cpp) |