mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-10-25 23:08:57 +08:00
update
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"translatedContent": "<p>动物收容所。有家动物收容所只收容狗与猫,且严格遵守“先进先出”的原则。在收养该收容所的动物时,收养人只能收养所有动物中“最老”(由其进入收容所的时间长短而定)的动物,或者可以挑选猫或狗(同时必须收养此类动物中“最老”的)。换言之,收养人不能自由挑选想收养的对象。请创建适用于这个系统的数据结构,实现各种操作方法,比如<code>enqueue</code>、<code>dequeueAny</code>、<code>dequeueDog</code>和<code>dequeueCat</code>。允许使用Java内置的LinkedList数据结构。</p>\n\n<p><code>enqueue</code>方法有一个<code>animal</code>参数,<code>animal[0]</code>代表动物编号,<code>animal[1]</code>代表动物种类,其中 0 代表猫,1 代表狗。</p>\n\n<p><code>dequeue*</code>方法返回一个列表<code>[动物编号, 动物种类]</code>,若没有可以收养的动物,则返回<code>[-1,-1]</code>。</p>\n\n<p><strong>示例1:</strong></p>\n\n<pre><strong> 输入</strong>:\n["AnimalShelf", "enqueue", "enqueue", "dequeueCat", "dequeueDog", "dequeueAny"]\n[[], [[0, 0]], [[1, 0]], [], [], []]\n<strong> 输出</strong>:\n[null,null,null,[0,0],[-1,-1],[1,0]]\n</pre>\n\n<p><strong>示例2:</strong></p>\n\n<pre><strong> 输入</strong>:\n["AnimalShelf", "enqueue", "enqueue", "enqueue", "dequeueDog", "dequeueCat", "dequeueAny"]\n[[], [[0, 0]], [[1, 0]], [[2, 1]], [], [], []]\n<strong> 输出</strong>:\n[null,null,null,null,[2,1],[0,0],[1,0]]\n</pre>\n\n<p><strong>说明:</strong></p>\n\n<ol>\n\t<li>收纳所的最大容量为20000</li>\n</ol>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Easy",
|
||||
"likes": 37,
|
||||
"likes": 41,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
@@ -143,7 +143,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"13.6K\", \"totalSubmission\": \"23.2K\", \"totalAcceptedRaw\": 13598, \"totalSubmissionRaw\": 23191, \"acRate\": \"58.6%\"}",
|
||||
"stats": "{\"totalAccepted\": \"14.2K\", \"totalSubmission\": \"24.2K\", \"totalAcceptedRaw\": 14164, \"totalSubmissionRaw\": 24198, \"acRate\": \"58.5%\"}",
|
||||
"hints": [
|
||||
"让我们假设用不同的列表存储猫和狗。怎样才能找到所有物种中最老的动物呢?要有创意。",
|
||||
"可以考虑为狗和猫保留一个链表,然后遍历它找到第一只狗(或猫)。这样做的影响是什么?",
|
||||
|
||||
Reference in New Issue
Block a user