Google interview question

Boxes on a shelf leetcode