Frage im Vorstellungsgespräch bei Globant

I was asked a programming Leetcode-type question in Javascript