Datadog interview question

Two leetcode medium questions for the first round.