Simple Java solution || beats 100%
\nclass Solution {\n    public int findCircleNum(int[][] isConnected) {\n        boolean visited[] = new boolean[isConnected.length];\n        int res = 0;\n   
```\nclass Solution {\n    public int findCircleNum(int[][] isConnected) {\n        boolean visited[] = new boolean[isConnected.length];\n        int res = 0;\n        for(int i = 0; i < visited.length; i++){\n            if(visited[i] == false){\n                dfs(isConnected,i, visited);\n                res++;\n            }\n        }\n        return res;\n    }\n    public void dfs(int[][] isConnected,int i, boolean[] visited){\n        if(visited[i]) return ;\n        visited[i] = true;\n        for(int j = 0; j < isConnected.length; j++){\n            if(isConnected[i][j] == 1 && j != i){\n                dfs(isConnected,j,visited);\n            }\n        }\n    }\n}\n```
['Depth-First Search', 'Breadth-First Search', 'Graph', 'Java']