standard java dfs solution (easy to understand)
\nclass Solution {\n    public int findCircleNum(int[][] isConnected) {\n        List<List<Integer>> adj = new ArrayList<>();\n        int n = isConnected.lengt
```\nclass Solution {\n    public int findCircleNum(int[][] isConnected) {\n        List<List<Integer>> adj = new ArrayList<>();\n        int n = isConnected.length;\n        for(int i=0;i<n;i++)\n            adj.add(new ArrayList());\n        \n        for(int i=0;i<n;i++)\n        {\n            for(int j=0;j<n;j++)\n            {\n                if(i == j)\n                    continue;\n                if(isConnected[i][j] == 1)\n                    adj.get(i).add(j);\n            }\n        }\n        int ans = 0;\n        boolean vis[] = new boolean[n];\n        for(int i=0;i<n;i++)\n        {\n            if(vis[i] == false) \n            {\n                ans++;\n                dfs(adj,i,vis);\n            }\n        }\n        return ans;\n    }\n    void dfs(List<List<Integer>> adj,int src,boolean[] vis)\n    {\n        vis[src] = true;\n        \n        for(int nbr : adj.get(src))\n        {\n            if(vis[nbr] == false)\n                dfs(adj,nbr,vis);\n        }\n    }\n}\n```\nPlease upvote if u find my code easy to understand
['Depth-First Search', 'Java']