Revolut interview question

LeetCode question with binary trees.