// here in my code some test case are not passed so kindly //let me know how can i correct this …
// here is my code …
#include
using namespace std;
int main() {
int n;
cin>>n;
int prev;
bool isvalid=true;
bool isdecreasing=true;
cin>>prev;
while (–n)
{
int curr;
cin>>curr;
if(curr==prev)
{
isvalid=false;
break;
}
else if(curr>prev)
{
isdecreasing=false;
}
else if(isdecreasing && curr<prev)
{
isvalid=false;
break;
}
prev=curr;
}
if(isvalid)
{
cout<<“true”;
}
else{
cout<<“false”;
}
return 0;
}
Partial test case passed
the question says that you need to check if the the whole array can be partitioned somewhere such that initial numbers are increasing and remaining are decreasing
eg 1 2 3 4 9 8 7 6 can be divided into 1 2 3 4 5 9 (increasing) and 8 7 6 (decreasing)
for implementation difficulties check this I’ve commented properly https://ide.codingblocks.com/s/656052
thank you for helping me. this means a lot for me.
