Amazon interview question

coding questions, time complexity , approach to the problem