Publicis Sapient interview question

Leetcode type question which I'd say was easy.