×

# Need help in Hackerrank: Impressing the Boss

 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 07 Apr '18, 15:35 0★montycs 105●7 accept rate: 0% 1 4 13 15 12 14 (07 Apr '18, 16:55)

 0 check out this test case:- 1 6 1 66 77 44 55 999. For this test case try all possible locations for which we will modify 1 to n, and try all possible values we want to use(min(a[i]) to max(a[i])) and finally we need to check the array is sorted or not.Time complexity will be O(pow(n,2)*max(a[i]). answered 07 Apr '18, 18:13 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: 07 Apr '18, 15:35

question was seen: 270 times

last updated: 07 Apr '18, 18:13