Available question text
For each index, compute the sum of absolute differences between its index and all other indices with the same value; if no duplicates exist, the sum is 0. The challenge is to do this efficiently for up to 1e5 elements by grouping equal values and using prefix/suffix sums over each group's index list to compute each sum in constant time per index.
Related questions
Continue with questions that share topics or the same question type.
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
No company association
Leetcode 2615. Sum of Distances
Reported date not specified · 0 source reports
Source snapshot: Nov 12, 2026
View source