Amazon interview question

Time / space complexity realted questions