Solved LeetCode program · 414 of 1,000
#0559 · Maximum Depth of N-ary Tree
Original English source
Keep a shared values holding 1, 3, 2, 4, 5, and 6. Keep a shared parents holding -1, 0, 0, 0, 1, and 1. Keep a shared bestdepth of 0.
To descend from node (a whole number) with level (a whole number). If level is more than bestdepth, set bestdepth to level. For every candidate from 0 to 5, if item candidate of parents is node, descend from candidate with level plus 1.
Descend from 0 with 1. Show bestdepth.
Expected stdout
3