Solved LeetCode program · 990 of 1,000
#1367 · Linked List in Binary Tree
Original English source
Keep a shared heads holding 4, 2, and 8. Keep a shared values holding 1, 4, 4, 2, 2, 1, 6, 8, 1, and 3. Keep a shared lefts holding 1, -1, 4, 5, 6, -1, -1, 8, -1, and -1. Keep a shared rights holding 2, 3, -1, -1, 7, -1, -1, 9, -1, and -1. Keep a shared found of 0. Keep a shared last of 0.
Set last to the last position of heads.
To match from node (a whole number) with depth (a whole number). If node is less than 0, return. If found is 1, return. If item node of values is not item depth of heads, return. If depth is last, set found to 1, return. Match from item node of lefts with depth plus 1. Match from item node of rights with depth plus 1.
For every node from 0 to 9.
Match from node with 0.
If found is 1, show true, otherwise show false.
Expected stdout
true