Publicis Sapient Interview Question

Leetcode type question which I'd say was easy.