Failing Perf test case in Rotting orange sum

All my performance test cases are failing.
I have used two for loops to add all the rotten oranges in the queue and then performed BFS. I got timeout expired error, so I thought I can not travel through the entire grid to find the rotten oranges.
But when I saw the approach video, they have used the same approach.
Give some suggestions.
I’m using python to solve the problem

@Haaris Did you get the testcases unlocked? You should be able to download it from the hints panel and debug it from there. Was it not available to you?

Yes I got the Hint
It is giving me the expected answer
it’s a problem with time of execution, but i my solution has similar time complexity compared to the approach video’s solution.

Hey,

From what I understood after going through your code, you have unnecessarily used the path array. Try to solve the problem without using it as it is redundant to use it. Also, the no of oranges you need to rot is only the no of fresh oranges in the given matrix. Try using this 2 hints to solve the problem and it will easily pass all the performance test cases.

1 Like

I made the path as set instead of list. It worked. Thanks for the help :slightly_smiling_face: :v:

Closing this topic as your issue has been resolved by the community. If not Kindly un-mark the accepted solution to re-open the topic or feel free to create a new topic and post a link to this topic as a reference.