Comments

Suppose this is not optimal, and k’ + c (c ≤ 0) roads can be shut down. It should be c >= 0

I had the same problem .... i tried to hack similar O(n) solution of kishan197 but unsuccessful . :(