← SAP questions

Sum of differences of repeated elements

Filed under SAP

Given an integer array `nums`, return an array `ans` of the same length where `ans[i]` is the sum of absolute differences between `i` and all other indices `j` such that `nums[j] == nums[i]` (i.e. |i…

You've read your 3 free write-ups

Sign up free to keep reading. Your account opens the first 10 questions of every company.

Related SAP questions

Collected from public candidate posts and coding forums. Updated Nov 2026.