Dodomeki
Sign in

27. Symmetric Tree

Easy

Given the root of a binary tree, return the root of the tree with the left and right sides swapped at every node. The input must remain unchanged.

Example 1
Input: raiz = [4, 2, 7, 1, 3, 6, 9]
Output: [4, 7, 2, 9, 6, 3, 1]
Example 2
Input: raiz = []
Output: []
Constraints
  • 0 <= quantidade de nós <= 10^4
TreesDFS
Caso 1
raiz =
[4,2,7,1,3,6,9]
Expected =
[4,7,2,9,6,3,1]
Caso 2
raiz =
[]
Expected =
[]

Run checks these 2 cases. Submit runs all 6, including hidden ones.