You are not logged in. Please login at to post your questions!


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

This question is marked "community wiki".

asked 22 Aug '17, 18:59

rishird94's gravatar image

accept rate: 0%

wikified 23 Aug '17, 08:26

Hey @rishird94,

To solve the problem, there are three basic condition

  1. Shouldn't be in order (increasing)
  2. if there n chapters than chapters cannot be greater than n
  3. 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

sandeep_007's gravatar image

accept rate: 15%


If you have any other query comment below, I'll try to help!

(22 Aug '17, 19:30) sandeep_0074★

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) rishird940★

Here this test case 1


2 1 3

(23 Aug '17, 13:27) sandeep_0074★

For the above test case, the answer should be yes but your program gives output no because of

if(a[i]== 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) sandeep_0074★
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • 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:


question asked: 22 Aug '17, 18:59

question was seen: 150 times

last updated: 23 Aug '17, 13:30