Friend Circles(LeetCode 547):

Problem