Atlassian interview question

Leetcode medium question, nothing special