Linked List in Binary Tree LeetCode solution in Java
1class Solution {2public boolean isSubPath(ListNode head, TreeNode root) {3if (root == null) return false;4if (issame(head, root)) return true;5return isSubPath(head, root.left) || isSubPath(head, root.right);6}78private boolean issame(ListNode head, TreeNode root) {9if (head == null) return true;10if (root == null) return false;11if (head.val != root.val) return false;12return issame(head.next, root.left) || issame(head.next, root.right);13}14}