Help me in solving SWAPFLIP problem

My issue

i am not getting how to solve this question even after seeing many correct submissions for this,can someone please explain the approach to write the code in this?

Problem Link: Swap and Flip Practice Coding Problem

Basically find the difference in the no. of 1 or 0 from both the string
if the difference is even we can easily convert the string by doing multiple operation

int n;cin>>n;
	    int cnt1=0,cnt2=0;
	    string s;cin>>s;
	    for(auto i:s){
	        if(i=='1')cnt1++;
	        else cnt2++;
	    }
	    cin>>s;
	    for(auto i:s){
	        if(i=='1')cnt1--;
	        else cnt2--;
	    }
	    if(cnt1%2==0 && cnt2%2==0)cout<<"Yes\n";
	    else cout<<"No\n";