Search
⌘K

Leetcode 2731. Movement of Robots

Robots move 1 unit/sec left or right and instantly swap directions on collision; compute the sum of pairwise distances after d seconds modulo 1e9+7. Using the observation that collisions only swap identities (so final positions are nums[i] ± d), the task reduces to efficiently computing the sum of absolute differences among those final coordinates (e.g., via sorting and prefix sums).


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.