-
Notifications
You must be signed in to change notification settings - Fork 20.1k
Closed
Description
Is your feature request related to a problem? Please describe.
Check whether a binary tree is symmetric or not.
Describe the solution you'd like
- Recursively check for left and right subtree of root
-
- left subtrees root's values should be equal right subtree's root value
-
- recursively check with left subtrees' left child VS right subtree's right child AND
- left subtree's right child VS right subtree left child
Ex.
Below is a symmetric tree
1
/ \
2 2
/ \ / \
3 4 4 3
Below is not symmetric because values is different in last level
1
/ \
2 2
/ \ / \
3 5 4 3
Describe alternatives you've considered
Suggested optimal solution
Additional context
Metadata
Metadata
Assignees
Labels
No labels