Search
⌘K

Leetcode 3426. Manhattan Distances of All Arrangements of Pieces

Compute the total sum of pairwise Manhattan distances over all ways to place k identical pieces on an m×n grid (one per cell), modulo 1e9+7. The core challenge is combinatorial counting: for each pair of cells count how many arrangements include that pair (choose the other k−2 cells) and exploit that Manhattan distance separates into independent row and column contributions to aggregate efficiently.


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.