Question d’entretien chez Samsung Research America

Medium question from Leetcode - codility test