Bloomberg interview question

Medium Leetcode style question about arrays