×

# can anyone tell me where i am going wrong? i am unable to figure out

 0 This question is marked "community wiki". asked 22 Aug '17, 18:59 20●4 accept rate: 0%

 4 Hey @rishird94, To solve the problem, there are three basic condition Shouldn't be in order (increasing) if there n chapters than chapters cannot be greater than n If a chapter is repeated then also output will be no. I think your solution goes wrong for 3rd condition. Check out this solution in C. Hope this helps! answered 22 Aug '17, 19:29 782●7 accept rate: 15% 1 If you have any other query comment below, I'll try to help! (22 Aug '17, 19:30) actualy,i have taken care of the third condition acc to me. because in my solution, as soon as the first occurence of a particular num happens in the input array, the same num from the 'ar' array list is removed,so wen there is 2nd occurence of that same number in the input array,it wont find it in the "ar" araylist and hence will exit with a no. can u please suggest a test case for wich it wont be successful? (22 Aug '17, 22:20) Here this test case 1 3 2 1 3 (23 Aug '17, 13:27) For the above test case, the answer should be yes but your program gives output no because of if(a[i]== i+1)  continue; ar.add((i+1));  See that, the value of A[i] can be at a position equal to the number but it shouldn't be in order. (23 Aug '17, 13:30)
 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:

×1,214
×1,125
×552

question asked: 22 Aug '17, 18:59

question was seen: 150 times

last updated: 23 Aug '17, 13:30