Untitled
unknown
plain_text
2 years ago
523 B
9
Indexable
function ArrayChallenge(strArr) {
function isSymmetric(node1, node2) {
if (node1 === node2 && (node1 === '#' || node1 === null)) {
return true;
}
if (node1 === '#' || node2 === '#' || node1 !== node2) {
return false;
}
return (
isSymmetric(strArr[node1][1], strArr[node2][2]) &&
isSymmetric(strArr[node1][2], strArr[node2][1])
);
}
// Start recursion with the root node and its left and right children
return isSymmetric(0, 1) && isSymmetric(0, 2);
}Editor is loading...