Two Sigma Interview Question

Friend circles hackerrank