Loading Similar Posts
signed callerFunc() {
//cin>>n;
string s;
cin>>s;
int n = s.size();
int ans = 0;
vector<int> res;
unordered_set<int> st;
for(int i=0;i<n;i++){
vector<int> tmp;
int cur = s[i]-'a',mask=0,m = res.size();
for(int i =0;i<m;i++){
if(res[i]!=cur) tmp.push_back(res[i]);
}
tmp.push_back(cur);
m = tmp.size();
res = tmp;
for(int j=m-1;j>=0;j--){
mask|=(1<<res[j]);
if(st.find(mask)==st.end()){
++ans;
st.insert(mask);
}
}
}
cout<<ans<<endl;
return 1;
}
Simple logic : Can only create a unique set of size 26. Brute force a 26*n solution.
cool