×

# Help in understanding the problem

 0 I am trying to solve this problem: Impressing the Boss. I am simply checking if the next element is smaller than the current element and this approach seems to pass half of the test cases but it is failing some. Please help in understanding the error in my approach. Here is my implementation: #include #include using namespace std; void printAnswer(int a[], int n) { int c = 0; for(int i=1;i 1) cout<<"NO"<>t; while(t --) { int n; cin>>n; int a[n]; for(int i=0;i>a[i]; printAnswer(a,n); } return 0; }  asked 03 Apr '18, 10:37 0★montycs 105●7 accept rate: 0%

 1 I have followed a different approach and this is the link to my code. Hope that helps :) answered 03 Apr '18, 22:50 53●4 accept rate: 0% I don't get the bit where you have used del() function.. I am not getting why you are comparing indexes instead of values.. (05 Apr '18, 11:22) montycs0★
 0 TAKE TWO CASES FOR new value addding either to previous or to next while(T--) { int n; cin>>n; int arr[n],b[n]; for(int i=0;i>arr[i]; b[i]=arr[i]; } int flag=0; for(int i=1;iarr[i]){ /if(arr[i-1]>arr[i+1]){ flag=1; wrong checking here consider the case: 8 6 6 break;}/ arr[i]=arr[i-1],b[i-1]=b[i]; break; //cnt++; } } bool a_is_ok=true,b_is_ok=true; for(int i=1;i
 0 Your code will fail for 8 6 6 9 9 198 9 try solving for these answered 03 Apr '18, 12:33 11●1 accept rate: 0%
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×310

question asked: 03 Apr '18, 10:37

question was seen: 387 times

last updated: 06 Apr '18, 11:52