Amazon interview question

Look up leet code hard