leetcode

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

commit c8b1a228cfc22ed4f29d1877f317802c7b30a6bf
parent 1211fafde7ffa16436079624c71668c7517a5525
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date:   Tue,  4 Apr 2023 17:06:35 +0200

Daily Problem

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

diff --git a/Problems/2405.cpp b/Problems/2405.cpp @@ -0,0 +1,18 @@ +class Solution { +public: + int partitionString(string s) { + bitset<26> st; + int res = 0; + for (char c : s) { + int n = c - 'a'; + if (!st[n]) + st.set(n); + else { + res++; + st.reset(); + st.set(n); + } + } + return res + 1; + } +}; diff --git a/README.md b/README.md @@ -493,6 +493,7 @@ for solving problems. | 2368 | Medium | [Reachable Nodes With Restrictions](Problems/2368.cpp) | | 2374 | Medium | [Node With Highest Edge Score](Problems/2374.cpp) | | 2390 | Medium | [Removing Stars From a String](Problems/2390.cpp) | +| 2405 | Medium | [Optimal Partition of String](Problems/2405.cpp) | | 2421 | Medium | [Number of Good Paths](Problems/2421.cpp) | | 2444 | Hard | [Count Subarrays With Fixed Bounds](Problems/2444.cpp) | | 2461 | Medium | [Maximum Sum of Distinct Subarrays With Length K](Problems/2461.cpp) |