Amazon Interview Question

coding questions, time complexity , approach to the problem