Skip to content

Commit b25b354

Browse files
committed
Create README - LeetHub
1 parent 5f1c3f1 commit b25b354

File tree

1 file changed

+40
-0
lines changed
  • 2684-maximum-number-of-moves-in-a-grid

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<h2><a href="https://leetcode.com/problems/maximum-number-of-moves-in-a-grid/">2684. Maximum Number of Moves in a Grid</a></h2><h3>Medium</h3><hr><div><p>You are given a <strong>0-indexed</strong> <code>m x n</code> matrix <code>grid</code> consisting of <strong>positive</strong> integers.</p>
2+
3+
<p>You can start at <strong>any</strong> cell in the first column of the matrix, and traverse the grid in the following way:</p>
4+
5+
<ul>
6+
<li>From a cell <code>(row, col)</code>, you can move to any of the cells: <code>(row - 1, col + 1)</code>, <code>(row, col + 1)</code> and <code>(row + 1, col + 1)</code> such that the value of the cell you move to, should be <strong>strictly</strong> bigger than the value of the current cell.</li>
7+
</ul>
8+
9+
<p>Return <em>the <strong>maximum</strong> number of <strong>moves</strong> that you can perform.</em></p>
10+
11+
<p>&nbsp;</p>
12+
<p><strong class="example">Example 1:</strong></p>
13+
<img alt="" src="https://assets.leetcode.com/uploads/2023/04/11/yetgriddrawio-10.png" style="width: 201px; height: 201px;">
14+
<pre><strong>Input:</strong> grid = [[2,4,3,5],[5,4,9,3],[3,4,2,11],[10,9,13,15]]
15+
<strong>Output:</strong> 3
16+
<strong>Explanation:</strong> We can start at the cell (0, 0) and make the following moves:
17+
- (0, 0) -&gt; (0, 1).
18+
- (0, 1) -&gt; (1, 2).
19+
- (1, 2) -&gt; (2, 3).
20+
It can be shown that it is the maximum number of moves that can be made.</pre>
21+
22+
<p><strong class="example">Example 2:</strong></p>
23+
24+
<pre><img alt="" src="https://assets.leetcode.com/uploads/2023/04/12/yetgrid4drawio.png">
25+
<strong>Input:</strong> grid = [[3,2,4],[2,1,9],[1,1,7]]
26+
<strong>Output:</strong> 0
27+
<strong>Explanation:</strong> Starting from any cell in the first column we cannot perform any moves.
28+
</pre>
29+
30+
<p>&nbsp;</p>
31+
<p><strong>Constraints:</strong></p>
32+
33+
<ul>
34+
<li><code>m == grid.length</code></li>
35+
<li><code>n == grid[i].length</code></li>
36+
<li><code>2 &lt;= m, n &lt;= 1000</code></li>
37+
<li><code>4 &lt;= m * n &lt;= 10<sup>5</sup></code></li>
38+
<li><code>1 &lt;= grid[i][j] &lt;= 10<sup>6</sup></code></li>
39+
</ul>
40+
</div>

0 commit comments

Comments
 (0)