Datadog Interview Question

Asked to code on a whiteboard.