Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
523 B
0
Indexable
Never
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);
}