The TransCompilator

Solved LeetCode program · 422 of 1,000

#0572 · Subtree of Another Tree

Easy Depth-First Search chunk-09.md

Original English source

Keep a shared values holding 3, 4, 5, 1, and 2. Keep a shared lefts holding 1, 3, -1, -1, and -1. Keep a shared rights holding 2, 4, -1, -1, and -1. Keep a shared targetvalues holding 4, 1, and 2. Keep a shared targetlefts holding 1, -1, and -1. Keep a shared targetrights holding 2, -1, and -1. Keep a shared alike of 0. Keep a shared found of 0.
To compare from one (a whole number) with two (a whole number). If alike is 0, return. If one is less than 0 and two is less than 0, return. If one is less than 0, set alike to 0, return. If two is less than 0, set alike to 0, return. If item one of values is not item two of targetvalues, set alike to 0, return. Compare from item one of lefts with item two of targetlefts. Compare from item one of rights with item two of targetrights.

To seek from node (a whole number). If node is less than 0, return. Set alike to 1. Compare from node with 0. If alike is 1, set found to 1, return. Seek from item node of lefts. Seek from item node of rights.

Seek from 0. If found is 1, show true, otherwise show false.

Open in Playground Browse all 1,000 problems

Expected stdout

true