Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Bracket107 {
- public:
- int yetanother(string s) {
- int L=s.size(),i,x,y;
- set<string> S;
- FOR(x,L) {
- string s1=s.substr(0,x)+s.substr(x+1);
- FOR(y,L) S.insert(s1.substr(0,y)+s[x]+s1.substr(y));
- }
- int ret=0;
- FORR(r,S) if(r!=s) {
- int ok=1;
- int cur=0;
- FORR(r2,r) {
- if(r2=='(') cur++;
- else cur--;
- if(cur<0) ok=0;
- }
- ret += ok;
- }
- return ret;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement