Amazon interview question

Leetcode easy-medium question from Tree Stack