Domanda di colloquio di Spectral MD

graph question from leetcode (but C++ was mandatory)