MCPcopy Create free account
hub / github.com/Tiwarishashwat/InterviewCodes / isSubPath

Method isSubPath

LinkedListInBinaryTree.java:8–16  ·  view source on GitHub ↗
(ListNode head, TreeNode root)

Source from the content-addressed store, hash-verified

6 return dfs( head.next, node.left) || dfs( head.next, node.right);
7 }
8 public boolean isSubPath(ListNode head, TreeNode root) {
9 if(root == null) return false;
10 if(root.val == head.val){
11 if(dfs(head,root)){
12 return true;
13 }
14 }
15 return isSubPath( head, root.left) || isSubPath( head, root.right);
16 }
17}

Callers

nothing calls this directly

Calls 1

dfsMethod · 0.95

Tested by

no test coverage detected