Class Solution
java.lang.Object
g1301_1400.s1367_linked_list_in_binary_tree.Solution
1367 - Linked List in Binary Tree.<p>Medium</p>
<p>Given a binary tree <code>root</code> and a linked list with <code>head</code> as the first node.</p>
<p>Return True if all the elements in the linked list starting from the <code>head</code> correspond to some <em>downward path</em> connected in the binary tree otherwise return False.</p>
<p>In this context downward path means a path that starts at some node and goes downwards.</p>
<p><strong>Example 1:</strong></p>
<p><strong><img src="https://assets.leetcode.com/uploads/2020/02/12/sample_1_1720.png" alt="" /></strong></p>
<p><strong>Input:</strong> head = [4,2,8], root = [1,4,4,null,2,2,null,1,null,6,8,null,null,null,null,1,3]</p>
<p><strong>Output:</strong> true</p>
<p><strong>Explanation:</strong> Nodes in blue form a subpath in the binary Tree.</p>
<p><strong>Example 2:</strong></p>
<p><strong><img src="https://assets.leetcode.com/uploads/2020/02/12/sample_2_1720.png" alt="" /></strong></p>
<p><strong>Input:</strong> head = [1,4,2,6], root = [1,4,4,null,2,2,null,1,null,6,8,null,null,null,null,1,3]</p>
<p><strong>Output:</strong> true</p>
<p><strong>Example 3:</strong></p>
<p><strong>Input:</strong> head = [1,4,2,6,8], root = [1,4,4,null,2,2,null,1,null,6,8,null,null,null,null,1,3]</p>
<p><strong>Output:</strong> false</p>
<p><strong>Explanation:</strong> There is no path in the binary tree that contains all the elements of the linked list from <code>head</code>.</p>
<p><strong>Constraints:</strong></p>
<ul>
<li>The number of nodes in the tree will be in the range <code>[1, 2500]</code>.</li>
<li>The number of nodes in the list will be in the range <code>[1, 100]</code>.</li>
<li><code>1 <= Node.val <= 100</code> for each node in the linked list and binary tree.</li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
isSubPath
-