LeetCode 100
Same Tree
Concepts:
Tree
Description: Given the roots of two binary trees p and q, write a function to check if they are the same or not.
Optimal Approach
Simple recursion, check if the values of the current nodes are equal and recursively check the left and right subtrees.
Time: O(n + m)
Space: O(1), Recursive stack space: O(n)