Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Linked List in Binary Tree

XPChallenge Points: 20
levelLevel: Medium

Check if the linked list appears exactly in the binary tree by following a downward path (only moving from parent to child).

The starting point in the tree can be any node.
If there exists a path downward where node values match the list in order, return true, otherwise return false.

Example 1:

Input: head = [7, 3] root = [7, 3, 5]

Output: true

Explanation:

Starting at the root, 7 → 3 matches the linked list.

Example 2:

Input: head = [2, 4, 6] root = [2, 4, null, 6]

Output: true

Explanation:

Downward path matches exactly.

Example 3:

Input: head = [1, 9] root = [1, 2, 3, 4]

Output: false

Explanation:

No downward path equals the linked list.

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result