[Python] - Simple & Clean Solution - Using DFS
Code\n\nclass Solution:\n    def findCircleNum(self, g: List[List[int]]) -> int:\n        v = [False] * len(g)\n\n        def dfs(i):\n            for j in rang
# Code\n```\nclass Solution:\n    def findCircleNum(self, g: List[List[int]]) -> int:\n        v = [False] * len(g)\n\n        def dfs(i):\n            for j in range(len(g)):\n                if g[i][j] and not v[j]:\n                    v[j] = True\n                    dfs(j)\n\n        ans = 0\n        for i in range(len(g)):\n            if not v[i]:\n                dfs(i)\n                ans += 1\n        return ans\n```
['Depth-First Search', 'Graph', 'Python3']