Point72 interview question

Hackerrank