Ambiguity in Chef in Queue

I understood problem, but stuck at one of the testcase that i drawn:

For e.g. chefs in the queue are [2,2,1,1], in this case should consider junior for 2 at index 2 or at 3 (0-based indexing).

If i consider at 1 at index 2, then answer will be 32= 6
considering at index 3, then answer will be 4
3= 12
or i should consider any junior with each senior?

The question mentions that we have to consider the junior chef which is least ahead of the chef. Hence, we will consider consider chef at index 2 as junior and hence the answer would be 3*2=6.

The line from the problem statement.
“Head Chef gets an interesting thought past his head. He begins to think what if every chef starting from the end of the queue begins to delegate his job of submitting bills to a chef least ahead of him in the queue but junior to him.”

1 Like

how 3 * 2 = 6 what 3 means for ?
can you expain me how 3 came

i am not understanding question can anyone give me 2 or 3 example .

Consider the case [2,2,1,1] (the same case as given by @shubh_singh). For the chef at position 0, the chef which is nearest to him and junior to him will be the chef at position 2 (0-based indexing), so the fearfulness of this scenario is 2-0+1=3.
For the chef at position 1, the chef which is nearest to him and junior to him will be the chef at position 2, so the fearfulness of this scenario is 2-1+1=2.
Since, the rest of the chefs in the queue are the junior most chef hence, the fearfulness will be 1.
Hence, the total fearfulness will be 3*2=6.

1 Like

thanks understood but one question 2211 have 2 have 2 junior un fornt of him.
position chef 0 index have 2 junior position 1 and 2?