Frage im Vorstellungsgespräch bei Bloomberg

Hackerrank question related to data structures and algorithms