Pergunta de entrevista da empresa Microsoft

problem solved by using moving window