ISHGAME - Editorial

https://www.codechef.com/LICO2020/problems/ISHGAME

The first thing to note is that the length of B doesn’t matter. We only need the unique characters and they are at max 26. Just create a set consisting of all unique letters of B. now iterate over A, if the element is not present in the set, then add it to the resultant string.

#include <bits/stdc++.h>
using namespace std;
int main()
{
	int t;
	cin>>t;
	while(t--){
		string a,b;
		cin>>a>>b;
		set<char>s1;
		// As explained, we only need unique values of b, which I am doing by making a set
		for(auto it:b){
			s1.insert(it);
		}
		// create a resultant string
		string res="";
		// iterate over all characters of a 
		for(auto it:a){
			// Check if the character is present in the set

			if(s1.find(it)==s1.end()){
				// if not present then add it to resultant array
				res+=it;
			}
		}
		cout<<res<<endl;
	}
	return 0;
}