Practice Minimum Moves to Spread Stones Over Grid
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Minimum Moves to Spread Stones Over Grid
Problem Statement
You are given a 0-indexed 2D integer matrix grid of size 3 * 3, representing the number of stones in each cell. The grid contains exactly 9 stones, and there can be multiple stones in a single cell. In one move, you can move a single stone from its current cell to any other cell if the two cells share a side. Return the minimum number of moves required to place one stone in each cell.
Source: Minimum Moves to Spread Stones Over Grid on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
grid = [[1,1,0],[1,1,1],[1,2,1]]
3
# Example 2
grid = [[1,3,0],[1,0,0],[1,0,3]]
4
Constraints
Related LeetCode Problems
Practice more problems similar to Minimum Moves to Spread Stones Over Grid.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.