static int friendCircles(String[] friends) {
        int circleCount = 0;
        Queue<Integer> queue = new LinkedList<>();

        for (int i = 0; i < friends.length; i++) {
            for (int j = 0; j < friends[i].length(); j++) {
                if (friends[i].charAt(j) == 'Y') {
                    circleCount++;
                    queue.add(i);
                    friends[i] = friends[i].replaceFirst("Y", "V");
                    while (!queue.isEmpty()) {
                        int indexOfFriends = queue.poll();
                        friends[indexOfFriends] = findFriendsInRow(queue, friends[indexOfFriends]);
                    }

                }
            }
        }
        return circleCount;
    }