Intuition
Code
Python3
Big O Analysis
-
Runtime
The runtime complexity here is since we are visiting every node in the tree.
-
Memory
The memory usage is since we are not using any extra data structure (other than the input binary tree).
— A
Search