Topics: DFS, BFS, DP, graph

Intuition

Number of nodes in a perfect binary tree with n level:

num_nodes = (2**n)-1

Implementation

 

Visual