Atlassian interview question

Leetcode Problem in Technical Interview