Datadog Interview Question

2 parts of algorithms problems.