I was solving this problem on the CSES Problemset Longest Flight Route.
Here is my code
The code is getting Accepted in all but 2 testcases(TLE in those 2) .
I cannot debug with those testcases since they are HUGE. I reckon that the problem is in my BFS Code but I can't seem to find why it would go in an infinity loop. If anyone could provide a testcase or something it would be incredibly helpful. Thanks.