Sample Test cases are working but wrong answer on submit..!

Jewels & Stones Solution: 52411510
Sample test cases are passing but wrong answer on submit.

#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main() {
	int T;
	cin>>T;
	while(T--){
	    int c=0;
	    char ch;
	    string st1,st2;
	    cin>>st1>>st2;
	    set<char> s1(begin(st1),end(st1)), s2(begin(st2),end(st2));
	    for(auto it1=s1.begin();it1!=s1.end();it1++){
	        if(s2.find(*it1)!=s2.end()){
	            c++;
	        }
	    }
	    cout << c << endl;
	}
	return 0;
}

I don’t know whats the problem.

What answer do you get for

1
a
aaa
1 Like

I’m getting 1 answer.
Its correct right!

No, the first string identifies character a as a jewel, and the second string - which is what you are evaluating for the presence of jewels - has three such characters in it.
Similarly

1
ab
aaccbbbccaa

should give 7.

1 Like

thanks @joffan, I have corrected it.
Its passed now. here it is Solution: 52470415 | CodeChef