I am getting the wrong answer for the 9th test case which is actually the sample test case mentioned in the problem. I did run the code with this case and got the expected answer but OJ says the wrong answer. what to do?
Wrong Answer for 9th test case, but running correct when manually inputting the same
please share code link
#include
using namespace std;
int main()
{
int n;
cin>>n;
long long int s[n];
for(int i=0;i<n;i++)
{
cin>>s[i];
}
/*for(int i=0;i<n;i++)
{
cout<<s[i]<<" ";
}
cout<<endl;
*/
int i=0;
while(s[i]>s[i+1])
{
i++;
}
//cout<<"i is "<<i<<endl;
int ans=1;
/*if (i==0)
{
ans=0;
}*/
{
for(int j=i+1;j<n;j++)
{
if (s[j-1]>s[j])
{
ans=0;
break;
}
}
}
if (ans==0)
cout<<"false"<<endl;
else
cout<<"true"<<endl;
return 0;
}
Hey,
the only problem i could feel was
Explanation
Carefully read the conditions to judge which all sequences may be valid. Don’t use arrays or lists.
is stated in the question.
try using same logic without using array.
do update if u are still facing any problem.
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.