Datadog interview question

Leet code medium-hard exercise on the first live coding