Goldman Sachs interview question

Leetcode Medium/Hard question about graphs and trees