Pregunta de entrevista de GlobalLogic

time complexity, space complexity for java problem