first and second. Check whether they are the same tree.
Two trees are the same when they have the same shape (matching nodes have children on exactly the same sides) and matching nodes hold equal values. Two empty trees count as the same.
Return True if the trees are identical, and False otherwise.first=tree_node([6, 2, 8, None, 4]), second=tree_node([6, 2, 8, None, 4]) → True
Shape and values match at every node.
first=tree_node([6, 2, 8]), second=tree_node([6, 8, 2]) → False
The shape is the same, but 2 and 8 sit on opposite sides of the root.
first=tree_node([5, 5]), second=tree_node([5, None, 5]) → False
The values are the same, but in the second tree the child is on the right, not the left.
Node.val ≤ 10^4first=tree_node([6, 2, 8, None, 4]), second=tree_node([6, 2, 8, None, 4])
True
Run checks the first 3 tests in your browser. Submit checks all 135 tests on the server, hidden ones included.