Find connected region sizes in matrix | Meta Interview Question