You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
14 lines
259 B
14 lines
259 B
5 years ago
|
function treeEqual(node1, node2) {
|
||
|
if (!node1 && !node2) {
|
||
|
return true;
|
||
|
}
|
||
|
if (!node1 || !node2) {
|
||
|
return false;
|
||
|
}
|
||
|
return (
|
||
|
node1.val == node2.val &&
|
||
|
treeEqual(node1.left, node2.left) &&
|
||
|
treeEqual(node1.right, node2.right)
|
||
|
);
|
||
|
}
|