Pergunta de entrevista da empresa Two Sigma

Friend circle question leetcode