Taggd interview question

Medium DSA question based on arrays.