What do we exactly need to do in this problem? & what is this third test case?

same doubt please explain last test case

last test case

6 2

1 2 3 4 5 6

A B

all the possible combination are

AAAAAB

AABBBB

AAABBB

AAAABB

Hoping it would be helpful…

To all those people who are still finding trouble in understanding the third case, here goes an explanation:

6 2

A 2

B 6

means there are **6 fence**, and among them in front of **2** fences, color buckets are kept ( fence number **2** has color **A** bucket placed in front , fence number **6** has color **B** bucket placed in front ).

Now, let us assume Chef starts at fence A, Chef goes to left, paints all the fences, comes back to A, brush is again dipped in bucket with color A and he moves forward till fence 5 then on 6th fence, brush takes color B ( Because : **When Remy passes a paint bucket, the brush acquires the color in the bucket first.** )and 6th fence is painted with that. Hence, Chef makes the following pattern:

AAAAAB

Now, let us assume that Chef didn’t just enjoy that much of coloring so, he goes one step further. He moves one step towards left with color B, now the pattern becomes:

AAAABB

He still isn’t satisfied so he moves one step further, pattern becomes:

AAABBB

Still, not satisfied, moves one step more, pattern becomes:

AABBBB

Now, he comes at fence 2 and brush gets paint A, so either of the above patterns can be formed again.

So, in total, we get 4 different patterns.

Note that all of the above moves are valid because it is mentioned in the question that **A plank can be colored multiple times. A plank’s color is the latest color it is painted with.** Also, fence is completely colored in all above cases.

Hope this helps!

Is this test case possible 7 3 B 3 C 5 A 1

Hi @panther527! Please do not write down test cases here. Since order of input is not specified, any order of fence would work.

It says that coloring is complete when each plank is painted with some color. Does it mean that when he has two buckets in front of first plank and the last one, when he comes from first plank to the last he can not come back and plaint planks with the color from the last bucket because all the planks are painted already?

No, he can paint a plank as many times as he want.