Pregunta de entrevista de Amazon

Basic time complexity problems, alongside some simple coding