Domanda di colloquio di Samsung Research America

Medium question from Leetcode - codility test