Pregunta de entrevista de Toptal

A hardened version hard question in leetcode