0101. Symmetric Tree
Easy | Tree | 24 ms (99.01%), 14.2 MB (93.95%)
Last updated
Was this helpful?
Easy | Tree | 24 ms (99.01%), 14.2 MB (93.95%)
Last updated
Was this helpful?
Source: GitHub:
Given the root
of a binary tree, check whether it is a mirror of itself (i.e., symmetric around its center).
Iterative
If both nodes are null, move to the next loop without pushing any nodes onto the stack. If one of the nodes is null, return False. If two nodes' values are different, return False.
Recursive
If both nodes are null, return True. If one of the nodes is null, return False.