Domanda di colloquio di Amazon

coding questions, time complexity , approach to the problem