1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-08 08:51:42 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
2022-05-02 23:44:12 +08:00
parent 7ea03594b3
commit 2a71c78585
4790 changed files with 11696 additions and 10944 deletions

View File

@@ -12,7 +12,7 @@
"translatedContent": "<p>用一个大小为 <code>m x n</code> 的二维网格 <code>grid</code> 表示一个箱子。你有 <code>n</code> 颗球。箱子的顶部和底部都是开着的。</p>\n\n<p>箱子中的每个单元格都有一个对角线挡板,跨过单元格的两个角,可以将球导向左侧或者右侧。</p>\n\n<ul>\n\t<li>将球导向右侧的挡板跨过左上角和右下角,在网格中用 <code>1</code> 表示。</li>\n\t<li>将球导向左侧的挡板跨过右上角和左下角,在网格中用 <code>-1</code> 表示。</li>\n</ul>\n\n<p>在箱子每一列的顶端各放一颗球。每颗球都可能卡在箱子里或从底部掉出来。如果球恰好卡在两块挡板之间的 \"V\" 形图案,或者被一块挡导向到箱子的任意一侧边上,就会卡住。</p>\n\n<p>返回一个大小为 <code>n</code> 的数组 <code>answer</code> ,其中 <code>answer[i]</code> 是球放在顶部的第 <code>i</code> 列后从底部掉出来的那一列对应的下标,如果球卡在盒子里,则返回 <code>-1</code> 。</p>\n\n<p> </p>\n\n<p><strong>示例 1</strong></p>\n\n<p><strong><img alt=\"\" src=\"https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2020/12/26/ball.jpg\" style=\"width: 500px; height: 385px;\" /></strong></p>\n\n<pre>\n<strong>输入:</strong>grid = [[1,1,1,-1,-1],[1,1,1,-1,-1],[-1,-1,-1,1,1],[1,1,1,1,-1],[-1,-1,-1,-1,-1]]\n<strong>输出:</strong>[1,-1,-1,-1,-1]\n<strong>解释:</strong>示例如图:\nb0 球开始放在第 0 列上,最终从箱子底部第 1 列掉出。\nb1 球开始放在第 1 列上,会卡在第 2、3 列和第 1 行之间的 \"V\" 形里。\nb2 球开始放在第 2 列上,会卡在第 2、3 列和第 0 行之间的 \"V\" 形里。\nb3 球开始放在第 3 列上,会卡在第 2、3 列和第 0 行之间的 \"V\" 形里。\nb4 球开始放在第 4 列上,会卡在第 2、3 列和第 1 行之间的 \"V\" 形里。\n</pre>\n\n<p><strong>示例 2</strong></p>\n\n<pre>\n<strong>输入:</strong>grid = [[-1]]\n<strong>输出:</strong>[-1]\n<strong>解释:</strong>球被卡在箱子左侧边上。\n</pre>\n\n<p><strong>示例 3</strong></p>\n\n<pre>\n<strong>输入:</strong>grid = [[1,1,1,1,1,1],[-1,-1,-1,-1,-1,-1],[1,1,1,1,1,1],[-1,-1,-1,-1,-1,-1]]\n<strong>输出:</strong>[0,1,2,3,4,-1]\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>m == grid.length</code></li>\n\t<li><code>n == grid[i].length</code></li>\n\t<li><code>1 <= m, n <= 100</code></li>\n\t<li><code>grid[i][j]</code> 为 <code>1</code> 或 <code>-1</code></li>\n</ul>\n",
"isPaidOnly": false,
"difficulty": "Medium",
"likes": 129,
"likes": 133,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
@@ -161,7 +161,7 @@
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"31.5K\", \"totalSubmission\": \"45.5K\", \"totalAcceptedRaw\": 31492, \"totalSubmissionRaw\": 45479, \"acRate\": \"69.2%\"}",
"stats": "{\"totalAccepted\": \"31.8K\", \"totalSubmission\": \"45.9K\", \"totalAcceptedRaw\": 31813, \"totalSubmissionRaw\": 45913, \"acRate\": \"69.3%\"}",
"hints": [
"Use DFS.",
"Traverse the path of the ball downwards until you reach the bottom or get stuck."