Frage im Vorstellungsgespräch bei Amazon

coding questions, time complexity , approach to the problem