Linked List in Binary Tree LeetCode solution in Python
1# Runtime: 139 ms (Top 73.10%) | Memory: 16.3 MB (Top 54.16%)234class Solution(object):5def isSubPath(self, head, root):6if not root:7return False8if self.issame(head, root):9return True10return self.isSubPath(head, root.left) or self.isSubPath(head, root.right)1112def issame(self, head, root):13if not head:14return True15if not root:16return False17if head.val != root.val:18return False19return self.issame(head.next, root.left) or self.issame(head.next, root.right)