A toll loop that pays you
A toll network has n junctions numbered 0 to n - 1. Each entry of roads is [a, b, toll]: a one-way road from a to b that charges toll coins. A negative toll is a rebate: that road pays you. Return True if some loop of roads, starting and ending at the same junction, has tolls that add up to less than zero (a driver could repeat it forever and profit), otherwise False.
The loop may start at any junction. A road from a junction back to itself is a loop on its own, and the same two junctions may be joined by several roads.
Besides the tests, one large input (42 junctions, 16,384 loops) with a ~100 ms limit (scaled to your device's speed): brute force won't pass.
Examples
has_paying_loop(3, [[0,1,4],[1,2,-2],[2,0,-3]])→truehas_paying_loop(3, [[0,1,4],[1,2,-2],[2,0,-2]])→falsehas_paying_loop(4, [[0,1,5],[2,3,-1],[3,2,0]])→true