Goldman Sachs interview question

LC Hard - Graph problem