Pregunta de entrevista de Meta

OA graph question. Leetcode medium and hard