Skip to content

Commit 8a56572

Browse files
authored
Create 2405. Optimal Partition of String 4 apr (#138)
2 parents 6d463a0 + 0a98a51 commit 8a56572

File tree

1 file changed

+18
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)