Domanda di colloquio di Anonymous

A Leetcode medium question which was from graphs.