Sprout Social interview question

The question was a Leetcode - Easy/Medium