Approach hintTry it first, then revealHide
Activate nodes in increasing order of value, uniting each with already active neighbours. After each value, a component holding c nodes of that value adds c * (c - 1) / 2 paths; single nodes also count.
Activate nodes in increasing order of value, uniting each with already active neighbours. After each value, a component holding c nodes of that value adds c * (c - 1) / 2 paths; single nodes also count.