Pintu And Fruits WA

I’m getting WA for the following question tag: [CHPINTU]
(CHPINTU Problem - CodeChef)
The answer which I have coded is the following:

code link
Please tell me what I seem to be doing wrong since it doesn’t seem like I’m getting trapped into the ‘Zero Trap’ which it’s editorial talk about.

Bro I dont know think your approach is correct.Even if its correct you need to take care of the edge case when the type of fruit does not exist , so you cant take that fruit else your answer would turn out to be 0. Here’s the link to my code for reference:

thanks @codeanktik_099 It helped, I understood that my approach of handling ‘zero trap’ was incorrect.