Available question text
For each array index, compute the sum of absolute differences between its index and the indices of all other elements with the same value. With n up to 1e5, the key is to group indices by value and compute per-group contributions efficiently (e.g., using prefix sums) rather than doing quadratic pairwise distance checks.
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 2121. Intervals Between Identical Elements
Reported date not specified · 0 source reports
Source snapshot: Nov 12, 2026
View source