Amazon interview question

The asked me a leetcode hard type problem