help needed in DISHLIFE

here is d link to my code :
link to question :
im getting WA some test cases and TLE in one test case…can anyone help me in dis ??

What are you trying to do, any comment on your thought process/algo used and way of implementing it??

Your code fails on this test case-

3 4
3 1 2 3 
3 1 2 3
1 4
Expected Output

I need your thought process to comment on coomplexity. I recommend checking the editorial as its very well written.

1 Like

Whenever you ask for doubt in a code, try to briefly describe your approach to help others understand it quickly. Otherwise its tedious to find a bug in others’ solutions.


your code is failing in this case:-

1 3 3 1 1 1 2 2 1 3
your output all expected output some

what you need to do is that first u need to see that which island contains the max. no. of ingredients and then evaluate them accordingly. for time complexity please upload your approach so that your code can be fully understood.