This problem introduces the pattern of tracking a global answer while computing local properties recursively — a technique used in many tree problems.
Enable JavaScript for the full StreamPrep guide.