Datadog Interview Question

Question was algorithms-esque, pretty much LC medium