Regarding DEC18 Chef and Meatballs

I am quite confused about DEC18 Chef and Meatballs because since the explanation of the example test states that ‘The meatballs are sorted in ascending order of meatiness’ (I suppose that it means 1 < 2 < 3 < 4 < 5 < 6) the first query (1, 2, 3, 4, 5) returns (3, 4) which are the 2-nd and 3-rd meatiest balls, while I expect it returns (2, 3).

Am I wrong or the example has problems ?


Since this is an ongoing contest, I would not say much.

Firstly, the example is absolutely correct.

The query returns the 3rd and 4th meatiest meat balls out of the five inputted. In the example test case, it returns 3 and 4 as they are the third and fourth meatiest respectively.


If we’re given 5 meatballs with 5 being the meatiest and 1 the least, 5 would be the first meatiest one, 4 the second, 3 the third and 2 the fourth meatiest meatball. Shouldn’t the output then be 3 2 instead of 3 4

1 Like

I too have the same doubt.

The example is correct. To clarify a bit, when the grader is given an input of 5 numbers, it arranges the numbers in increasing order of their meatiness and then returns the 3rd and the 4th number from the arranged order.


@sauravchirania For example: We have meatballs numbered as [1,2,3,4,5] and considering the amount of meat they contain [9,10,13,8,14] respectively then 5th ball is the meatiest, 3rd ball is the 2nd meatiest, 2nd ball is the 3rd meatiest, 1st ball is the 4th meatiest as per the question (correct me if I am wrong).

Grader:2 1

And according to you- [4,1,2,3,5] and their meatiness [8,9,10,13,14]

Grader:2 3

Good question. The language used in that problem is confusing, and unfortunately you need to work out the meaning from the example, which I think you have done correctly. In normal English descriptions, the two index numbers returned are for the third and second meatiest meatballs. They are wrongly described as the third and fourth meatiest because they are the third and fourth entries in an ascending sorted list of the meatballs.

@admin this needs correcting/clarifying in the problem.

Further explanation:
Given a test sample of meatballs, the feedback given is the 3rd and 4th entries in the following list sorted in ascending order of meatiness:

  • least meaty
  • 4th-most meaty
  • 3rd-most meaty <<<<
  • 2nd-most meaty <<<<
  • Meatiest

@fakeid_v15 in the example you have given, the grader will return 2 3.

I agree that the problem statement is a bit ambiguous but if you look at the sample test case given in the problem and the explanation I have given in my previous comment, you should be able to understand it.

PS: I am not sure how to reply to a comment so I had to add this as a separate comment.

@admin I’m not sure how notification works so I’m pinging you in a comment also to correct/clarify this question

Think of it like, the grader will sort the number in increasing order and then return the 3rd and 4th meatiest meatball number…

Let the meat balls arranged as : [5,8,1,2,9,10]


? 1 2 3 4 5 :: Grader -> 1,2

? 1 2 6 4 5 :: Grdader -> 2,5

@thang040602 can u please explain the question if u understood

@catchup Same problem I’m facing

Just keep in mind that the grader will give 2nd and 3rd meatiest meatballs.
I have done this way and I am getting correct answer.

Try this way!

Good luck !

If it was 3rd and 4th, would it be even solvable?

what output will i get if i repeat the number of meatballs? ex. [1,2,4,4,4]

It’s clearly mentioned in the question that all numbers have to be distinct. Hence your question is invalid.

well the language was definitely not clear at all from the question please @admin take this into account.

I had asked this exact doubt in the comment section of the question but the author did not reply unfortunately.

basically, the question was worded wrongly and you had to understand and consider the testcase and ignore the wording.