TikTok Interview Question

given a tree possibly order