โ† Goldman Sachs questions

Cost to Move All 1s to Each Index

Filed under Goldman Sachs

Given a binary array, calculate the total cost to move all 1s to every possible index, where moving an element from index i to j costs abs(i - j).

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 Goldman Sachs questions

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