String window: getting WA in some testcases pls tell the problem in the code

code is below

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

int main(){

string s1,s2;
getline(cin,s1);
getline(cin,s2);

int l=0,i=0,j=0;
int min=INT_MAX;
string s3;
int start=0;

// cout<<s1.length()<<" “<<s2.length()<<”\n";
while(i<s1.length()){

	    if(s1[i]==s2[0]){
	    	l=0;
	    }
		if(s1[i]==s2[j]){

// cout<<s2[j]<<" “<<i<<” “<<j<<” “<<l<<” “;
i++;
j++;
l++;
if(j==s2.length()){
// cout<<“yes”;
// cout<<l<<” ";
if(min>l){
min=l;
start=i-l;
}
j=0;

		}
	
		}
		else if(s1[i]!=s2[j]){
			i++;
			l++;
		}
	}

s3=s1.substr(start,min);
cout<<s3<<"\n";

}

Check this testcase, your code gives wrong answer on this input

qwerty asdfgh qazxsw saq
qas

Output for this code must be

saq

but your code outputs

qazxsw

In the question it is given that you need to print the minimum length substring which contains all the characters of string2. Not necessarily in same order.
Your code only considers substrings which have the characters in the same order. Your code gives correct output for this similar input.
Input

qwerty asdfgh qazxsw qas
qas

Output

qas

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.