TopH Decent Arrays Solution

Solve  in C:

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,t,f=0,ar[1001],n,a[1001];
    while(cin>>n)
    {
        for(i=0; i<n; i++)
        {
            cin>>ar[i];

        }
        for(i=1; i<n; i++)
        {
            if(ar[i-1]>ar[i])
            {
              f=1;
              break;
            }


        }
        if(f==1)
            cout<<"No"<<endl;
        else
            cout<<"Yes"<<endl;
            f=0;
    }
}

No comments

Most View Post

Recent post

RESTful APIs with CRUD Operations in Laravel 12| (2025)

  RESTful APIs serve as the foundation of modern web development. They follow a set of rules called Representational State Transfer (REST) t...

Powered by Blogger.