NAME2 question can anyone explain how to do it

#include<bits/stdc++.h>
using namespace std;
int main(){
int t;
cin>>t;
while(t–){
string m,w;
cin>>m>>w;
int l1,l2;
l1=m.length();
l2=w.length();
if(m==w)
{
cout<<“YES”<<endl;
}
else if (l1>=l2)
{
cout<<“NO”<<endl;
}
else
{
int j=0,count=0,k=0,c=0;
for(int i=0;i<w.length()&&j<l1;i++)
{
if(w[i]==m[j])
{
count++;
j++;
}

  }
    
    
   
   if(count>= l1)
   cout<<"YES"<<endl;
   else
   cout<<"NO"<<endl;
    }

}

return 0;

The task is to find whether A is a subsequence of B or vice versa. See my code below, I have created two functions. The second function checks whether the string is a subsequence of other and the first function checks for both the cases i.e. either A is of B or B is of A and returns true for either of the cases.

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

bool f1(string a,string b);
bool f2(string a,string b);
int main()
{
int t;
cin >> t;
while(t–)
{
string a,b;
cin >> a >> b;
if(f1(a,b))
cout << “YES” << “\n”;
else
cout << “NO” << “\n”;
}
return 0;
}
bool f2(string a, string b)
{
int check=0;
int alength=a.length();
int blength=b.length();

for(int i=0;i<blength;i++)
	if(b[i]==a[check])
		check++;

if(alength==check)
	return true;
else
    return false;	

}
bool f1(string a,string b)
{
if(f2(a,b)|| f2(b,a))
return true;
else
return false;
}