SLB interview question

Leetcode medium-hard on graph algorithms.