1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/出界的路径数 [out-of-boundary-paths].html
2022-03-29 12:43:11 +08:00

31 lines
1.4 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>给你一个大小为 <code>m x n</code> 的网格和一个球。球的起始坐标为 <code>[startRow, startColumn]</code> 。你可以将球移到在四个方向上相邻的单元格内(可以穿过网格边界到达网格之外)。你 <strong>最多</strong> 可以移动 <code>maxMove</code> 次球。</p>
<p>给你五个整数 <code>m</code><code>n</code><code>maxMove</code><code>startRow</code> 以及 <code>startColumn</code> ,找出并返回可以将球移出边界的路径数量。因为答案可能非常大,返回对 <code>10<sup>9</sup> + 7</code> <strong>取余</strong> 后的结果。</p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2021/04/28/out_of_boundary_paths_1.png" style="width: 500px; height: 296px;" />
<pre>
<strong>输入:</strong>m = 2, n = 2, maxMove = 2, startRow = 0, startColumn = 0
<strong>输出:</strong>6
</pre>
<p><strong>示例 2</strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2021/04/28/out_of_boundary_paths_2.png" style="width: 500px; height: 293px;" />
<pre>
<strong>输入:</strong>m = 1, n = 3, maxMove = 3, startRow = 0, startColumn = 1
<strong>输出:</strong>12
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= m, n &lt;= 50</code></li>
<li><code>0 &lt;= maxMove &lt;= 50</code></li>
<li><code>0 &lt;= startRow &lt; m</code></li>
<li><code>0 &lt;= startColumn &lt; n</code></li>
</ul>