2850. 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.
Example 1:
Example 2:
Constraints:
grid.length == grid[i].length == 3
0 <= grid[i][j] <= 9
Sum of
grid
is equal to9
.
Intuition
Links
https://leetcode.com/problems/minimum-moves-to-spread-stones-over-grid/description/
Video Links
https://www.youtube.com/watch?v=Ew3C223hd-E&ab_channel=AryanMittal
Approach 1:
C++
Approach 2:
C++
Approach 3:
C++
Approach 4:
C++
Similar Problems
Last updated