Skip to content

Commit 7b33771

Browse files
committed
Add C++ 19 20 Solutions
1 parent af9818e commit 7b33771

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
class Solution {
2+
public:
3+
int partitionString(string s) {
4+
int ans = 0;
5+
unordered_set<char> st;
6+
for (auto& c: s)
7+
{
8+
if (st.find(c) == st.end())
9+
{
10+
st.insert(c);
11+
}
12+
else
13+
{
14+
st.clear();
15+
st.insert(c);
16+
ans++;
17+
}
18+
}
19+
if (!st.empty()) ans++;
20+
return ans;
21+
}
22+
};

0 commit comments

Comments
 (0)