Linked List in Binary Tree

Given a binary tree root and a linked list with head as the first node.

Return True if all the elements in the linked list starting from the head correspond to some downward path connected in the binary tree otherwise return False.

In this context downward path means a path that starts at some node and goes downwards.

Example 1:

Example 2:

Example 3:

Constraints:

  • 1 <= node.val <= 100 for each node in the linked list and binary tree.

  • The given linked list will contain between 1 and 100 nodes.

  • The given binary tree will contain between 1 and 2500 nodes.

Last updated