Pregunta de entrevista de Meta

Algorithm coding questions, with time and space complexity.