Pergunta de entrevista da empresa SquareShift

A medium hard problem solving question, followed by Java core basics.