Categorygithub.com/szhou12/leetcode-goleetcode3249-Count-the-Number-of-Good-Nodes
package
0.0.0-20241220224003-b7cf03a90b2b
Repository: https://github.com/szhou12/leetcode-go.git
Documentation: pkg.go.dev

# README

3249. Count the Number of Good Nodes

Solution idea

BFS + DFS

  1. BFS: BFS建树。因为只给了edges [][]int, 并且无法判断[a, b]谁是父节点谁是子节点
  2. DFS: DFS统计以当前节点为根时,它下辖的每个分支的节点数

Time complexity = $O(V+E)$