Symmetric tree
Easytreedfsbfsrecursion
Return true if the tree is a mirror of itself (symmetric around its root).
Examples write a tree level by level, with null for a missing child: [3,9,20,null,null,15,7].
Example 1
Input: root = [1,2,2,3,4,4,3] Output: true
Example 2
Input: root = [1,2,2,null,3,null,3] Output: false
Constraints
- 1 ≤ number of nodes ≤ 1000
- -100 ≤ Node.val ≤ 100
Submit checks your solution against 10 tests, including hidden ones.
// Provided by the judge: keep these definitions
class TreeNode {
constructor(val = 0, left = null, right = null) {
this.val = val
this.left = left
this.right = right
}
}
/**
* @param {TreeNode|null} root
* @return {bool}
*/
function isSymmetric(root) {
}