1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-05 23:41:41 +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>0</code> 和 <code>1</code> 表示。所有学生站在一个队列里,每个学生要么喜欢圆形的要么喜欢方形的。<br>\n餐厅里三明治的数量与学生的数量相同。所有三明治都放在一个 <strong>栈</strong> 里,每一轮:</p>\n\n<ul>\n\t<li>如果队列最前面的学生 <strong>喜欢</strong> 栈顶的三明治,那么会 <strong>拿走它</strong> 并离开队列。</li>\n\t<li>否则,这名学生会 <strong>放弃这个三明治</strong> 并回到队列的尾部。</li>\n</ul>\n\n<p>这个过程会一直持续到队列里所有学生都不喜欢栈顶的三明治为止。</p>\n\n<p>给你两个整数数组 <code>students</code> 和 <code>sandwiches</code> ,其中 <code>sandwiches[i]</code> 是栈里面第 <code>i<sup></sup></code> 个三明治的类型(<code>i = 0</code> 是栈的顶部), <code>students[j]</code> 是初始队列里第 <code>j<sup></sup></code> 名学生对三明治的喜好(<code>j = 0</code> 是队列的最开始位置)。请你返回无法吃午餐的学生数量。</p>\n\n<p> </p>\n\n<p><strong>示例 1</strong></p>\n\n<pre><b>输入:</b>students = [1,1,0,0], sandwiches = [0,1,0,1]\n<b>输出:</b>0<strong> \n解释</strong>\n- 最前面的学生放弃最顶上的三明治,并回到队列的末尾,学生队列变为 students = [1,0,0,1]。\n- 最前面的学生放弃最顶上的三明治,并回到队列的末尾,学生队列变为 students = [0,0,1,1]。\n- 最前面的学生拿走最顶上的三明治,剩余学生队列为 students = [0,1,1],三明治栈为 sandwiches = [1,0,1]。\n- 最前面的学生放弃最顶上的三明治,并回到队列的末尾,学生队列变为 students = [1,1,0]。\n- 最前面的学生拿走最顶上的三明治,剩余学生队列为 students = [1,0],三明治栈为 sandwiches = [0,1]。\n- 最前面的学生放弃最顶上的三明治,并回到队列的末尾,学生队列变为 students = [0,1]。\n- 最前面的学生拿走最顶上的三明治,剩余学生队列为 students = [1],三明治栈为 sandwiches = [1]。\n- 最前面的学生拿走最顶上的三明治,剩余学生队列为 students = [],三明治栈为 sandwiches = []。\n所以所有学生都有三明治吃。\n</pre>\n\n<p><strong>示例 2</strong></p>\n\n<pre><b>输入:</b>students = [1,1,1,0,0,1], sandwiches = [1,0,0,0,1,1]\n<b>输出:</b>3\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 &lt;= students.length, sandwiches.length &lt;= 100</code></li>\n\t<li><code>students.length == sandwiches.length</code></li>\n\t<li><code>sandwiches[i]</code> 要么是 <code>0</code> ,要么是 <code>1</code> 。</li>\n\t<li><code>students[i]</code> 要么是 <code>0</code> ,要么是 <code>1</code> 。</li>\n</ul>\n",
"isPaidOnly": false,
"difficulty": "Easy",
"likes": 34,
"likes": 37,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
@@ -155,7 +155,7 @@
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"11K\", \"totalSubmission\": \"15.7K\", \"totalAcceptedRaw\": 10963, \"totalSubmissionRaw\": 15725, \"acRate\": \"69.7%\"}",
"stats": "{\"totalAccepted\": \"11.5K\", \"totalSubmission\": \"16.5K\", \"totalAcceptedRaw\": 11502, \"totalSubmissionRaw\": 16525, \"acRate\": \"69.6%\"}",
"hints": [
"Simulate the given in the statement",
"Calculate those who will eat instead of those who will not."