Avanze Group interview question

Leetcode easy medium problem based on trees