Subscribe Us

Responsive Advertisement

Advertisement

1638B Odd Swap Sort codeforces solution in cpp

 1638B Odd Swap Sort codeforces solution in cpp

by ujjal roy




#include<bits/stdc++.h>

using namespace std;

main()

{

    int t,n,a,me,mo,c,i;

    cin>>t;

    while(t--)

    {

        cin>>n;

        int a[n];

        me=-1;

        mo=-1;

        c=0;

        for(i=0;i<n;i++)

        {

            cin>>a[i];

            if(a[i]%2==0)

            {

                if(a[i]>=me) me=a[i];

                else c=1;

            }

            else

            {

                if(a[i]>=mo) mo=a[i];

                else c=1;

            }

        }

        if(c) cout<<"NO"<<endl;

        else cout<<"YES"<<endl;


    }


    return 0;

}


Post a Comment

0 Comments