I got a problem very similar with friend circles. The only difference is in Hackerrank the input is a List of String instead of a 2-D array.
https://leetcode.com/problems/friend-circles/