node_count stations numbered from 1 to node_count. Each links[i] = [a, b] is a cable between stations a and b. The network may be split into several separate parts.
You may lay at most two new cables, or none at all. A cable cannot run from a station to itself, and you cannot add a second cable between two stations that are already linked.
Return True if, after that, every station can end up with an even number of cables, and False otherwise.node_count=5, links=[[1, 2], [2, 3], [3, 4], [4, 5]] → True
Only stations 1 and 5 have an odd number of cables, and they are not linked yet, so one new cable 1–5 is enough.
node_count=5, links=[[1, 2], [2, 3], [3, 1], [1, 4]] → True
Stations 1 and 4 are odd, but they are already linked. Station 5 is linked to neither of them, so cables 1–5 and 4–5 fix both.
node_count=6, links=[[1, 2], [3, 4], [5, 6]] → False
All six stations are odd, and two new cables can fix at most four of them.
node_count=5, links=[[1, 2], [2, 3], [3, 4], [4, 5]]
True
Run checks the first 3 tests in your browser. Submit checks all 84 tests on the server, hidden ones included.