Solved LeetCode program · 111 of 1,000
#0111 · Minimum Depth of Binary Tree
Original English source
Keep a shared values holding 3, 9, 20, 15, and 7. Keep a shared lefts holding 1, -1, 3, -1, and -1. Keep a shared rights holding 2, -1, 4, -1, and -1. Keep a shared best of 1000000.
To walk from node (a whole number) with depth (a whole number). If node is less than 0, return. The left is item node of lefts. The right is item node of rights. If left is -1 and right is -1, if depth is less than best, set best to depth, return. Walk from left with depth plus 1. Walk from right with depth plus 1.
Walk from 0 with 1. Show best.
Expected stdout
2