Amazon interview question

One variant of Burn The Tree. Leetcode's Race Car Problem. Flatten The Tree Problem.