Goldman Sachs Interview Question

Two Leetcode medium graph challenge.