Bloomberg interview question

Leetcode Medium graph question + follow ups (time complexity)