Bentley Systems interview question

Problems on graph in leetcode.