|
6 | 6 | importjava.util.ArrayList; |
7 | 7 | importjava.util.List; |
8 | 8 |
|
9 | | -/** |
10 | | - * 1367. Linked List in Binary Tree |
11 | | - * |
12 | | - * Given a binary tree root and a linked list with head as the first node. |
13 | | - * Return True if all the elements in the linked list starting from the head correspond to some downward path |
14 | | - * connected in the binary tree otherwise return False. |
15 | | - * In this context downward path means a path that starts at some node and goes downwards. |
16 | | - * |
17 | | - * Example 1: |
18 | | - * Input: head = [4,2,8], root = [1,4,4,null,2,2,null,1,null,6,8,null,null,null,null,1,3] |
19 | | - * Output: true |
20 | | - * Explanation: Nodes in blue form a subpath in the binary Tree. |
21 | | - * |
22 | | - * Example 2: |
23 | | - * Input: head = [1,4,2,6], root = [1,4,4,null,2,2,null,1,null,6,8,null,null,null,null,1,3] |
24 | | - * Output: true |
25 | | - * |
26 | | - * Example 3: |
27 | | - * Input: head = [1,4,2,6,8], root = [1,4,4,null,2,2,null,1,null,6,8,null,null,null,null,1,3] |
28 | | - * Output: false |
29 | | - * Explanation: There is no path in the binary tree that contains all the elements of the linked list from head. |
30 | | - * |
31 | | - * Constraints: |
32 | | - * 1 <= node.val <= 100 for each node in the linked list and binary tree. |
33 | | - * The given linked list will contain between 1 and 100 nodes. |
34 | | - * The given binary tree will contain between 1 and 2500 nodes. |
35 | | - * */ |
36 | 9 | publicclass_1367 { |
37 | 10 | publicstaticclassSolution1 { |
38 | 11 | List<List<Integer>>paths =newArrayList<>(); |
|