mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-09 09:21:40 +08:00
移除零宽空格
This commit is contained in:
@@ -7,9 +7,9 @@
|
||||
"boundTopicId": 535066,
|
||||
"title": "Number of Students Unable to Eat Lunch",
|
||||
"titleSlug": "number-of-students-unable-to-eat-lunch",
|
||||
"content": "<p>The school cafeteria offers circular and square sandwiches at lunch break, referred to by numbers <code>0</code> and <code>1</code> respectively. All students stand in a queue. Each student either prefers square or circular sandwiches.</p>\n\n<p>The number of sandwiches in the cafeteria is equal to the number of students. The sandwiches are placed in a <strong>stack</strong>. At each step:</p>\n\n<ul>\n\t<li>If the student at the front of the queue <strong>prefers</strong> the sandwich on the top of the stack, they will <strong>take it</strong> and leave the queue.</li>\n\t<li>Otherwise, they will <strong>leave it</strong> and go to the queue's end.</li>\n</ul>\n\n<p>This continues until none of the queue students want to take the top sandwich and are thus unable to eat.</p>\n\n<p>You are given two integer arrays <code>students</code> and <code>sandwiches</code> where <code>sandwiches[i]</code> is the type of the <code>i<sup>th</sup></code> sandwich in the stack (<code>i = 0</code> is the top of the stack) and <code>students[j]</code> is the preference of the <code>j<sup>th</sup></code> student in the initial queue (<code>j = 0</code> is the front of the queue). Return <em>the number of students that are unable to eat.</em></p>\n\n<p> </p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:</strong> students = [1,1,0,0], sandwiches = [0,1,0,1]\n<strong>Output:</strong> 0<strong> \nExplanation:</strong>\n- Front student leaves the top sandwich and returns to the end of the line making students = [1,0,0,1].\n- Front student leaves the top sandwich and returns to the end of the line making students = [0,0,1,1].\n- Front student takes the top sandwich and leaves the line making students = [0,1,1] and sandwiches = [1,0,1].\n- Front student leaves the top sandwich and returns to the end of the line making students = [1,1,0].\n- Front student takes the top sandwich and leaves the line making students = [1,0] and sandwiches = [0,1].\n- Front student leaves the top sandwich and returns to the end of the line making students = [0,1].\n- Front student takes the top sandwich and leaves the line making students = [1] and sandwiches = [1].\n- Front student takes the top sandwich and leaves the line making students = [] and sandwiches = [].\nHence all students are able to eat.\n</pre>\n\n<p><strong class=\"example\">Example 2:</strong></p>\n\n<pre>\n<strong>Input:</strong> students = [1,1,1,0,0,1], sandwiches = [1,0,0,0,1,1]\n<strong>Output:</strong> 3\n</pre>\n\n<p> </p>\n<p><strong>Constraints:</strong></p>\n\n<ul>\n\t<li><code>1 <= students.length, sandwiches.length <= 100</code></li>\n\t<li><code>students.length == sandwiches.length</code></li>\n\t<li><code>sandwiches[i]</code> is <code>0</code> or <code>1</code>.</li>\n\t<li><code>students[i]</code> is <code>0</code> or <code>1</code>.</li>\n</ul>\n",
|
||||
"content": "<p>The school cafeteria offers circular and square sandwiches at lunch break, referred to by numbers <code>0</code> and <code>1</code> respectively. All students stand in a queue. Each student either prefers square or circular sandwiches.</p>\n\n<p>The number of sandwiches in the cafeteria is equal to the number of students. The sandwiches are placed in a <strong>stack</strong>. At each step:</p>\n\n<ul>\n\t<li>If the student at the front of the queue <strong>prefers</strong> the sandwich on the top of the stack, they will <strong>take it</strong> and leave the queue.</li>\n\t<li>Otherwise, they will <strong>leave it</strong> and go to the queue's end.</li>\n</ul>\n\n<p>This continues until none of the queue students want to take the top sandwich and are thus unable to eat.</p>\n\n<p>You are given two integer arrays <code>students</code> and <code>sandwiches</code> where <code>sandwiches[i]</code> is the type of the <code>i<sup>th</sup></code> sandwich in the stack (<code>i = 0</code> is the top of the stack) and <code>students[j]</code> is the preference of the <code>j<sup>th</sup></code> student in the initial queue (<code>j = 0</code> is the front of the queue). Return <em>the number of students that are unable to eat.</em></p>\n\n<p> </p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:</strong> students = [1,1,0,0], sandwiches = [0,1,0,1]\n<strong>Output:</strong> 0<strong> \nExplanation:</strong>\n- Front student leaves the top sandwich and returns to the end of the line making students = [1,0,0,1].\n- Front student leaves the top sandwich and returns to the end of the line making students = [0,0,1,1].\n- Front student takes the top sandwich and leaves the line making students = [0,1,1] and sandwiches = [1,0,1].\n- Front student leaves the top sandwich and returns to the end of the line making students = [1,1,0].\n- Front student takes the top sandwich and leaves the line making students = [1,0] and sandwiches = [0,1].\n- Front student leaves the top sandwich and returns to the end of the line making students = [0,1].\n- Front student takes the top sandwich and leaves the line making students = [1] and sandwiches = [1].\n- Front student takes the top sandwich and leaves the line making students = [] and sandwiches = [].\nHence all students are able to eat.\n</pre>\n\n<p><strong class=\"example\">Example 2:</strong></p>\n\n<pre>\n<strong>Input:</strong> students = [1,1,1,0,0,1], sandwiches = [1,0,0,0,1,1]\n<strong>Output:</strong> 3\n</pre>\n\n<p> </p>\n<p><strong>Constraints:</strong></p>\n\n<ul>\n\t<li><code>1 <= students.length, sandwiches.length <= 100</code></li>\n\t<li><code>students.length == sandwiches.length</code></li>\n\t<li><code>sandwiches[i]</code> is <code>0</code> or <code>1</code>.</li>\n\t<li><code>students[i]</code> is <code>0</code> or <code>1</code>.</li>\n</ul>\n",
|
||||
"translatedTitle": "无法吃午餐的学生数量",
|
||||
"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 <= students.length, sandwiches.length <= 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",
|
||||
"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 <= students.length, sandwiches.length <= 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": 173,
|
||||
|
Reference in New Issue
Block a user