Google Interview Question

A difficult Leetcode Problem about graph