Datadog interview question

Coding Interviews: Pattern matching, arrays, DFS