← All problemsSign in

2617. Minimum Number of Visited Cells in a Grid

LeetCodeArrayDynamic ProgrammingStackBreadth-First SearchUnion-FindHeap (Priority Queue)Open on judge ↗

You are given a 0-indexed m x n integer matrix grid. Your initial position is at the top-left cell (0, 0). Starting from the cell (i, j), you can move to one of the following cells: - Cells (i, k) with j < k <= grid[i][j] + j (rightward movement), or - Cells (k, j) with i < k <= grid[i][j] + i (downward movement). Return the minimum number of cells you need to visit to reach the bottom-right c

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start