Linked List in Binary Tree LeetCode solution in JavaScript

1
var isSubPath = function (head, root) {
2
if (!root) return false;
3
if (issame(head, root)) return true;
4
return isSubPath(head, root.left) || isSubPath(head, root.right);
5
};
6

7
function issame(head, root) {
8
if (!head) return true;
9
if (!root) return false;
10
if (head.val != root.val) return false;
11
return issame(head.next, root.left) || issame(head.next, root.right);
12
}

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0