1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-06 16:01:41 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
Files
leetcode-problemset/leetcode-cn/originData/implement-router.json
2025-04-24 21:29:06 +08:00

207 lines
44 KiB
JSON
Raw Permalink 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.

{
"data": {
"question": {
"questionId": "3827",
"questionFrontendId": "3508",
"categoryTitle": "Algorithms",
"boundTopicId": 3640673,
"title": "Implement Router",
"titleSlug": "implement-router",
"content": "<p>Design a data structure that can efficiently manage data packets in a network router. Each data packet consists of the following attributes:</p>\n\n<ul>\n\t<li><code>source</code>: A unique identifier for the machine that generated the packet.</li>\n\t<li><code>destination</code>: A unique identifier for the target machine.</li>\n\t<li><code>timestamp</code>: The time at which the packet arrived at the router.</li>\n</ul>\n\n<p>Implement the <code>Router</code> class:</p>\n\n<p><code>Router(int memoryLimit)</code>: Initializes the Router object with a fixed memory limit.</p>\n\n<ul>\n\t<li><code>memoryLimit</code> is the <strong>maximum</strong> number of packets the router can store at any given time.</li>\n\t<li>If adding a new packet would exceed this limit, the <strong>oldest</strong> packet must be removed to free up space.</li>\n</ul>\n\n<p><code>bool addPacket(int source, int destination, int timestamp)</code>: Adds a packet with the given attributes to the router.</p>\n\n<ul>\n\t<li>A packet is considered a duplicate if another packet with the same <code>source</code>, <code>destination</code>, and <code>timestamp</code> already exists in the router.</li>\n\t<li>Return <code>true</code> if the packet is successfully added (i.e., it is not a duplicate); otherwise return <code>false</code>.</li>\n</ul>\n\n<p><code>int[] forwardPacket()</code>: Forwards the next packet in FIFO (First In First Out) order.</p>\n\n<ul>\n\t<li>Remove the packet from storage.</li>\n\t<li>Return the packet as an array <code>[source, destination, timestamp]</code>.</li>\n\t<li>If there are no packets to forward, return an empty array.</li>\n</ul>\n\n<p><code>int getCount(int destination, int startTime, int endTime)</code>:</p>\n\n<ul>\n\t<li>Returns the number of packets currently stored in the router (i.e., not yet forwarded) that have the specified destination and have timestamps in the inclusive range <code>[startTime, endTime]</code>.</li>\n</ul>\n\n<p><strong>Note</strong> that queries for <code>addPacket</code> will be made in increasing order of <code>timestamp</code>.</p>\n\n<p>&nbsp;</p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<div class=\"example-block\">\n<p><strong>Input:</strong><br />\n<span class=\"example-io\">[&quot;Router&quot;, &quot;addPacket&quot;, &quot;addPacket&quot;, &quot;addPacket&quot;, &quot;addPacket&quot;, &quot;addPacket&quot;, &quot;forwardPacket&quot;, &quot;addPacket&quot;, &quot;getCount&quot;]<br />\n[[3], [1, 4, 90], [2, 5, 90], [1, 4, 90], [3, 5, 95], [4, 5, 105], [], [5, 2, 110], [5, 100, 110]]</span></p>\n\n<p><strong>Output:</strong><br />\n<span class=\"example-io\">[null, true, true, false, true, true, [2, 5, 90], true, 1] </span></p>\n\n<p><strong>Explanation</strong></p>\nRouter router = new Router(3); // Initialize Router with memoryLimit of 3.<br />\nrouter.addPacket(1, 4, 90); // Packet is added. Return True.<br />\nrouter.addPacket(2, 5, 90); // Packet is added. Return True.<br />\nrouter.addPacket(1, 4, 90); // This is a duplicate packet. Return False.<br />\nrouter.addPacket(3, 5, 95); // Packet is added. Return True<br />\nrouter.addPacket(4, 5, 105); // Packet is added, <code>[1, 4, 90]</code> is removed as number of packets exceeds memoryLimit. Return True.<br />\nrouter.forwardPacket(); // Return <code>[2, 5, 90]</code> and remove it from router.<br />\nrouter.addPacket(5, 2, 110); // Packet is added. Return True.<br />\nrouter.getCount(5, 100, 110); // The only packet with destination 5 and timestamp in the inclusive range <code>[100, 110]</code> is <code>[4, 5, 105]</code>. Return 1.</div>\n\n<p><strong class=\"example\">Example 2:</strong></p>\n\n<div class=\"example-block\">\n<p><strong>Input:</strong><br />\n<span class=\"example-io\">[&quot;Router&quot;, &quot;addPacket&quot;, &quot;forwardPacket&quot;, &quot;forwardPacket&quot;]<br />\n[[2], [7, 4, 90], [], []]</span></p>\n\n<p><strong>Output:</strong><br />\n<span class=\"example-io\">[null, true, [7, 4, 90], []] </span></p>\n\n<p><strong>Explanation</strong></p>\nRouter router = new Router(2); // Initialize <code>Router</code> with <code>memoryLimit</code> of 2.<br />\nrouter.addPacket(7, 4, 90); // Return True.<br />\nrouter.forwardPacket(); // Return <code>[7, 4, 90]</code>.<br />\nrouter.forwardPacket(); // There are no packets left, return <code>[]</code>.</div>\n\n<p>&nbsp;</p>\n<p><strong>Constraints:</strong></p>\n\n<ul>\n\t<li><code>2 &lt;= memoryLimit &lt;= 10<sup>5</sup></code></li>\n\t<li><code>1 &lt;= source, destination &lt;= 2 * 10<sup>5</sup></code></li>\n\t<li><code>1 &lt;= timestamp &lt;= 10<sup>9</sup></code></li>\n\t<li><code>1 &lt;= startTime &lt;= endTime &lt;= 10<sup>9</sup></code></li>\n\t<li>At most <code>10<sup>5</sup></code> calls will be made to <code>addPacket</code>, <code>forwardPacket</code>, and <code>getCount</code> methods altogether.</li>\n\t<li>queries for <code>addPacket</code> will be made in increasing order of <code>timestamp</code>.</li>\n</ul>\n",
"translatedTitle": "设计路由器",
"translatedContent": "<p>请你设计一个数据结构来高效管理网络路由器中的数据包。每个数据包包含以下属性:</p>\n\n<ul>\n\t<li><code>source</code>:生成该数据包的机器的唯一标识符。</li>\n\t<li><code>destination</code>:目标机器的唯一标识符。</li>\n\t<li><code>timestamp</code>:该数据包到达路由器的时间戳。</li>\n</ul>\n\n<p>实现 <code>Router</code> 类:</p>\n\n<p><code>Router(int memoryLimit)</code>:初始化路由器对象,并设置固定的内存限制。</p>\n\n<ul>\n\t<li><code>memoryLimit</code> 是路由器在任意时间点可以存储的 <strong>最大</strong> 数据包数量。</li>\n\t<li>如果添加一个新数据包会超过这个限制,则必须移除 <strong>最旧的</strong> 数据包以腾出空间。</li>\n</ul>\n\n<p><code>bool addPacket(int source, int destination, int timestamp)</code>:将具有给定属性的数据包添加到路由器。</p>\n\n<ul>\n\t<li>如果路由器中已经存在一个具有相同 <code>source</code>、<code>destination</code> 和 <code>timestamp</code> 的数据包,则视为重复数据包。</li>\n\t<li>如果数据包成功添加(即不是重复数据包),返回 <code>true</code>;否则返回 <code>false</code>。</li>\n</ul>\n\n<p><code>int[] forwardPacket()</code>:以 FIFO先进先出顺序转发下一个数据包。</p>\n\n<ul>\n\t<li>从存储中移除该数据包。</li>\n\t<li>以数组 <code>[source, destination, timestamp]</code> 的形式返回该数据包。</li>\n\t<li>如果没有数据包可以转发,则返回空数组。</li>\n</ul>\n\n<p><code>int getCount(int destination, int startTime, int endTime)</code></p>\n\n<ul>\n\t<li>返回当前存储在路由器中(即尚未转发)的,且目标地址为指定 <code>destination</code> 且时间戳在范围 <code>[startTime, endTime]</code>(包括两端)内的数据包数量。</li>\n</ul>\n\n<p><strong>注意</strong>:对于 <code>addPacket</code> 的查询会按照 <code>timestamp</code> 的递增顺序进行。</p>\n\n<p>&nbsp;</p>\n\n<p><strong class=\"example\">示例 1</strong></p>\n\n<div class=\"example-block\">\n<p><strong>输入:</strong><br />\n<span class=\"example-io\">[\"Router\", \"addPacket\", \"addPacket\", \"addPacket\", \"addPacket\", \"addPacket\", \"forwardPacket\", \"addPacket\", \"getCount\"]<br />\n[[3], [1, 4, 90], [2, 5, 90], [1, 4, 90], [3, 5, 95], [4, 5, 105], [], [5, 2, 110], [5, 100, 110]]</span></p>\n\n<p><strong>输出:</strong><br />\n<span class=\"example-io\">[null, true, true, false, true, true, [2, 5, 90], true, 1] </span></p>\n\n<p><strong>解释:</strong></p>\n<code>Router router = new Router(3);</code> // 初始化路由器,内存限制为 3。<br />\n<code>router.addPacket(1, 4, 90);</code> // 数据包被添加,返回 True。<br />\n<code>router.addPacket(2, 5, 90);</code> // 数据包被添加,返回 True。<br />\n<code>router.addPacket(1, 4, 90);</code> // 这是一个重复数据包,返回 False。<br />\n<code>router.addPacket(3, 5, 95);</code> // 数据包被添加,返回 True。<br />\n<code>router.addPacket(4, 5, 105);</code> // 数据包被添加,<code>[1, 4, 90]</code> 被移除,因为数据包数量超过限制,返回 True。<br />\n<code>router.forwardPacket();</code> // 转发数据包 <code>[2, 5, 90]</code> 并将其从路由器中移除。<br />\n<code>router.addPacket(5, 2, 110);</code> // 数据包被添加,返回 True。<br />\n<code>router.getCount(5, 100, 110);</code> // 唯一目标地址为 5 且时间在 <code>[100, 110]</code>&nbsp;范围内的数据包是 <code>[4, 5, 105]</code>,返回 1。</div>\n\n<p><strong class=\"example\">示例 2</strong></p>\n\n<div class=\"example-block\">\n<p><strong>输入:</strong><br />\n<span class=\"example-io\">[\"Router\", \"addPacket\", \"forwardPacket\", \"forwardPacket\"]<br />\n[[2], [7, 4, 90], [], []]</span></p>\n\n<p><strong>输出:</strong><br />\n<span class=\"example-io\">[null, true, [7, 4, 90], []] </span></p>\n\n<p><strong>解释:</strong></p>\n<code>Router router = new Router(2);</code> // 初始化路由器,内存限制为 2。<br />\n<code>router.addPacket(7, 4, 90);</code> // 返回 True。<br />\n<code>router.forwardPacket();</code> // 返回 <code>[7, 4, 90]</code>。<br />\n<code>router.forwardPacket();</code> // 没有数据包可以转发,返回 <code>[]</code>。</div>\n\n<p>&nbsp;</p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>2 &lt;= memoryLimit &lt;= 10<sup>5</sup></code></li>\n\t<li><code>1 &lt;= source, destination &lt;= 2 * 10<sup>5</sup></code></li>\n\t<li><code>1 &lt;= timestamp &lt;= 10<sup>9</sup></code></li>\n\t<li><code>1 &lt;= startTime &lt;= endTime &lt;= 10<sup>9</sup></code></li>\n\t<li><code>addPacket</code>、<code>forwardPacket</code> 和 <code>getCount</code> 方法的总调用次数最多为 <code>10<sup>5</sup></code>。</li>\n\t<li>对于 <code>addPacket</code> 的查询,<code>timestamp</code> 按递增顺序给出。</li>\n</ul>\n",
"isPaidOnly": false,
"difficulty": "Medium",
"likes": 2,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
"contributors": [],
"langToValidPlayground": "{\"cpp\": false, \"java\": false, \"python\": false, \"python3\": false, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"typescript\": false, \"bash\": false, \"php\": false, \"swift\": false, \"kotlin\": false, \"dart\": false, \"golang\": false, \"ruby\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"rust\": false, \"racket\": false, \"erlang\": false, \"elixir\": false, \"pythondata\": false, \"react\": false, \"vanillajs\": false, \"postgresql\": false, \"cangjie\": false}",
"topicTags": [
{
"name": "Design",
"slug": "design",
"translatedName": "设计",
"__typename": "TopicTagNode"
},
{
"name": "Queue",
"slug": "queue",
"translatedName": "队列",
"__typename": "TopicTagNode"
},
{
"name": "Array",
"slug": "array",
"translatedName": "数组",
"__typename": "TopicTagNode"
},
{
"name": "Hash Table",
"slug": "hash-table",
"translatedName": "哈希表",
"__typename": "TopicTagNode"
},
{
"name": "Binary Search",
"slug": "binary-search",
"translatedName": "二分查找",
"__typename": "TopicTagNode"
},
{
"name": "Ordered Set",
"slug": "ordered-set",
"translatedName": "有序集合",
"__typename": "TopicTagNode"
}
],
"companyTagStats": null,
"codeSnippets": [
{
"lang": "C++",
"langSlug": "cpp",
"code": "class Router {\npublic:\n Router(int memoryLimit) {\n \n }\n \n bool addPacket(int source, int destination, int timestamp) {\n \n }\n \n vector<int> forwardPacket() {\n \n }\n \n int getCount(int destination, int startTime, int endTime) {\n \n }\n};\n\n/**\n * Your Router object will be instantiated and called as such:\n * Router* obj = new Router(memoryLimit);\n * bool param_1 = obj->addPacket(source,destination,timestamp);\n * vector<int> param_2 = obj->forwardPacket();\n * int param_3 = obj->getCount(destination,startTime,endTime);\n */",
"__typename": "CodeSnippetNode"
},
{
"lang": "Java",
"langSlug": "java",
"code": "class Router {\n\n public Router(int memoryLimit) {\n \n }\n \n public boolean addPacket(int source, int destination, int timestamp) {\n \n }\n \n public int[] forwardPacket() {\n \n }\n \n public int getCount(int destination, int startTime, int endTime) {\n \n }\n}\n\n/**\n * Your Router object will be instantiated and called as such:\n * Router obj = new Router(memoryLimit);\n * boolean param_1 = obj.addPacket(source,destination,timestamp);\n * int[] param_2 = obj.forwardPacket();\n * int param_3 = obj.getCount(destination,startTime,endTime);\n */",
"__typename": "CodeSnippetNode"
},
{
"lang": "Python",
"langSlug": "python",
"code": "class Router(object):\n\n def __init__(self, memoryLimit):\n \"\"\"\n :type memoryLimit: int\n \"\"\"\n \n\n def addPacket(self, source, destination, timestamp):\n \"\"\"\n :type source: int\n :type destination: int\n :type timestamp: int\n :rtype: bool\n \"\"\"\n \n\n def forwardPacket(self):\n \"\"\"\n :rtype: List[int]\n \"\"\"\n \n\n def getCount(self, destination, startTime, endTime):\n \"\"\"\n :type destination: int\n :type startTime: int\n :type endTime: int\n :rtype: int\n \"\"\"\n \n\n\n# Your Router object will be instantiated and called as such:\n# obj = Router(memoryLimit)\n# param_1 = obj.addPacket(source,destination,timestamp)\n# param_2 = obj.forwardPacket()\n# param_3 = obj.getCount(destination,startTime,endTime)",
"__typename": "CodeSnippetNode"
},
{
"lang": "Python3",
"langSlug": "python3",
"code": "class Router:\n\n def __init__(self, memoryLimit: int):\n \n\n def addPacket(self, source: int, destination: int, timestamp: int) -> bool:\n \n\n def forwardPacket(self) -> List[int]:\n \n\n def getCount(self, destination: int, startTime: int, endTime: int) -> int:\n \n\n\n# Your Router object will be instantiated and called as such:\n# obj = Router(memoryLimit)\n# param_1 = obj.addPacket(source,destination,timestamp)\n# param_2 = obj.forwardPacket()\n# param_3 = obj.getCount(destination,startTime,endTime)",
"__typename": "CodeSnippetNode"
},
{
"lang": "C",
"langSlug": "c",
"code": "\n\n\ntypedef struct {\n \n} Router;\n\n\nRouter* routerCreate(int memoryLimit) {\n \n}\n\nbool routerAddPacket(Router* obj, int source, int destination, int timestamp) {\n \n}\n\nint* routerForwardPacket(Router* obj, int* retSize) {\n \n}\n\nint routerGetCount(Router* obj, int destination, int startTime, int endTime) {\n \n}\n\nvoid routerFree(Router* obj) {\n \n}\n\n/**\n * Your Router struct will be instantiated and called as such:\n * Router* obj = routerCreate(memoryLimit);\n * bool param_1 = routerAddPacket(obj, source, destination, timestamp);\n \n * int* param_2 = routerForwardPacket(obj, retSize);\n \n * int param_3 = routerGetCount(obj, destination, startTime, endTime);\n \n * routerFree(obj);\n*/",
"__typename": "CodeSnippetNode"
},
{
"lang": "C#",
"langSlug": "csharp",
"code": "public class Router {\n\n public Router(int memoryLimit) {\n \n }\n \n public bool AddPacket(int source, int destination, int timestamp) {\n \n }\n \n public int[] ForwardPacket() {\n \n }\n \n public int GetCount(int destination, int startTime, int endTime) {\n \n }\n}\n\n/**\n * Your Router object will be instantiated and called as such:\n * Router obj = new Router(memoryLimit);\n * bool param_1 = obj.AddPacket(source,destination,timestamp);\n * int[] param_2 = obj.ForwardPacket();\n * int param_3 = obj.GetCount(destination,startTime,endTime);\n */",
"__typename": "CodeSnippetNode"
},
{
"lang": "JavaScript",
"langSlug": "javascript",
"code": "/**\n * @param {number} memoryLimit\n */\nvar Router = function(memoryLimit) {\n \n};\n\n/** \n * @param {number} source \n * @param {number} destination \n * @param {number} timestamp\n * @return {boolean}\n */\nRouter.prototype.addPacket = function(source, destination, timestamp) {\n \n};\n\n/**\n * @return {number[]}\n */\nRouter.prototype.forwardPacket = function() {\n \n};\n\n/** \n * @param {number} destination \n * @param {number} startTime \n * @param {number} endTime\n * @return {number}\n */\nRouter.prototype.getCount = function(destination, startTime, endTime) {\n \n};\n\n/** \n * Your Router object will be instantiated and called as such:\n * var obj = new Router(memoryLimit)\n * var param_1 = obj.addPacket(source,destination,timestamp)\n * var param_2 = obj.forwardPacket()\n * var param_3 = obj.getCount(destination,startTime,endTime)\n */",
"__typename": "CodeSnippetNode"
},
{
"lang": "TypeScript",
"langSlug": "typescript",
"code": "class Router {\n constructor(memoryLimit: number) {\n \n }\n\n addPacket(source: number, destination: number, timestamp: number): boolean {\n \n }\n\n forwardPacket(): number[] {\n \n }\n\n getCount(destination: number, startTime: number, endTime: number): number {\n \n }\n}\n\n/**\n * Your Router object will be instantiated and called as such:\n * var obj = new Router(memoryLimit)\n * var param_1 = obj.addPacket(source,destination,timestamp)\n * var param_2 = obj.forwardPacket()\n * var param_3 = obj.getCount(destination,startTime,endTime)\n */",
"__typename": "CodeSnippetNode"
},
{
"lang": "PHP",
"langSlug": "php",
"code": "class Router {\n /**\n * @param Integer $memoryLimit\n */\n function __construct($memoryLimit) {\n \n }\n \n /**\n * @param Integer $source\n * @param Integer $destination\n * @param Integer $timestamp\n * @return Boolean\n */\n function addPacket($source, $destination, $timestamp) {\n \n }\n \n /**\n * @return Integer[]\n */\n function forwardPacket() {\n \n }\n \n /**\n * @param Integer $destination\n * @param Integer $startTime\n * @param Integer $endTime\n * @return Integer\n */\n function getCount($destination, $startTime, $endTime) {\n \n }\n}\n\n/**\n * Your Router object will be instantiated and called as such:\n * $obj = Router($memoryLimit);\n * $ret_1 = $obj->addPacket($source, $destination, $timestamp);\n * $ret_2 = $obj->forwardPacket();\n * $ret_3 = $obj->getCount($destination, $startTime, $endTime);\n */",
"__typename": "CodeSnippetNode"
},
{
"lang": "Swift",
"langSlug": "swift",
"code": "\nclass Router {\n\n init(_ memoryLimit: Int) {\n \n }\n \n func addPacket(_ source: Int, _ destination: Int, _ timestamp: Int) -> Bool {\n \n }\n \n func forwardPacket() -> [Int] {\n \n }\n \n func getCount(_ destination: Int, _ startTime: Int, _ endTime: Int) -> Int {\n \n }\n}\n\n/**\n * Your Router object will be instantiated and called as such:\n * let obj = Router(memoryLimit)\n * let ret_1: Bool = obj.addPacket(source, destination, timestamp)\n * let ret_2: [Int] = obj.forwardPacket()\n * let ret_3: Int = obj.getCount(destination, startTime, endTime)\n */",
"__typename": "CodeSnippetNode"
},
{
"lang": "Kotlin",
"langSlug": "kotlin",
"code": "class Router(memoryLimit: Int) {\n\n fun addPacket(source: Int, destination: Int, timestamp: Int): Boolean {\n \n }\n\n fun forwardPacket(): IntArray {\n \n }\n\n fun getCount(destination: Int, startTime: Int, endTime: Int): Int {\n \n }\n\n}\n\n/**\n * Your Router object will be instantiated and called as such:\n * var obj = Router(memoryLimit)\n * var param_1 = obj.addPacket(source,destination,timestamp)\n * var param_2 = obj.forwardPacket()\n * var param_3 = obj.getCount(destination,startTime,endTime)\n */",
"__typename": "CodeSnippetNode"
},
{
"lang": "Dart",
"langSlug": "dart",
"code": "class Router {\n\n Router(int memoryLimit) {\n \n }\n \n bool addPacket(int source, int destination, int timestamp) {\n \n }\n \n List<int> forwardPacket() {\n \n }\n \n int getCount(int destination, int startTime, int endTime) {\n \n }\n}\n\n/**\n * Your Router object will be instantiated and called as such:\n * Router obj = Router(memoryLimit);\n * bool param1 = obj.addPacket(source,destination,timestamp);\n * List<int> param2 = obj.forwardPacket();\n * int param3 = obj.getCount(destination,startTime,endTime);\n */",
"__typename": "CodeSnippetNode"
},
{
"lang": "Go",
"langSlug": "golang",
"code": "type Router struct {\n \n}\n\n\nfunc Constructor(memoryLimit int) Router {\n \n}\n\n\nfunc (this *Router) AddPacket(source int, destination int, timestamp int) bool {\n \n}\n\n\nfunc (this *Router) ForwardPacket() []int {\n \n}\n\n\nfunc (this *Router) GetCount(destination int, startTime int, endTime int) int {\n \n}\n\n\n/**\n * Your Router object will be instantiated and called as such:\n * obj := Constructor(memoryLimit);\n * param_1 := obj.AddPacket(source,destination,timestamp);\n * param_2 := obj.ForwardPacket();\n * param_3 := obj.GetCount(destination,startTime,endTime);\n */",
"__typename": "CodeSnippetNode"
},
{
"lang": "Ruby",
"langSlug": "ruby",
"code": "class Router\n\n=begin\n :type memory_limit: Integer\n=end\n def initialize(memory_limit)\n \n end\n\n\n=begin\n :type source: Integer\n :type destination: Integer\n :type timestamp: Integer\n :rtype: Boolean\n=end\n def add_packet(source, destination, timestamp)\n \n end\n\n\n=begin\n :rtype: Integer[]\n=end\n def forward_packet()\n \n end\n\n\n=begin\n :type destination: Integer\n :type start_time: Integer\n :type end_time: Integer\n :rtype: Integer\n=end\n def get_count(destination, start_time, end_time)\n \n end\n\n\nend\n\n# Your Router object will be instantiated and called as such:\n# obj = Router.new(memory_limit)\n# param_1 = obj.add_packet(source, destination, timestamp)\n# param_2 = obj.forward_packet()\n# param_3 = obj.get_count(destination, start_time, end_time)",
"__typename": "CodeSnippetNode"
},
{
"lang": "Scala",
"langSlug": "scala",
"code": "class Router(_memoryLimit: Int) {\n\n def addPacket(source: Int, destination: Int, timestamp: Int): Boolean = {\n \n }\n\n def forwardPacket(): Array[Int] = {\n \n }\n\n def getCount(destination: Int, startTime: Int, endTime: Int): Int = {\n \n }\n\n}\n\n/**\n * Your Router object will be instantiated and called as such:\n * val obj = new Router(memoryLimit)\n * val param_1 = obj.addPacket(source,destination,timestamp)\n * val param_2 = obj.forwardPacket()\n * val param_3 = obj.getCount(destination,startTime,endTime)\n */",
"__typename": "CodeSnippetNode"
},
{
"lang": "Rust",
"langSlug": "rust",
"code": "struct Router {\n\n}\n\n\n/** \n * `&self` means the method takes an immutable reference.\n * If you need a mutable reference, change it to `&mut self` instead.\n */\nimpl Router {\n\n fn new(memoryLimit: i32) -> Self {\n \n }\n \n fn add_packet(&self, source: i32, destination: i32, timestamp: i32) -> bool {\n \n }\n \n fn forward_packet(&self) -> Vec<i32> {\n \n }\n \n fn get_count(&self, destination: i32, start_time: i32, end_time: i32) -> i32 {\n \n }\n}\n\n/**\n * Your Router object will be instantiated and called as such:\n * let obj = Router::new(memoryLimit);\n * let ret_1: bool = obj.add_packet(source, destination, timestamp);\n * let ret_2: Vec<i32> = obj.forward_packet();\n * let ret_3: i32 = obj.get_count(destination, startTime, endTime);\n */",
"__typename": "CodeSnippetNode"
},
{
"lang": "Racket",
"langSlug": "racket",
"code": "(define router%\n (class object%\n (super-new)\n \n ; memory-limit : exact-integer?\n (init-field\n memory-limit)\n \n ; add-packet : exact-integer? exact-integer? exact-integer? -> boolean?\n (define/public (add-packet source destination timestamp)\n )\n ; forward-packet : -> (listof exact-integer?)\n (define/public (forward-packet)\n )\n ; get-count : exact-integer? exact-integer? exact-integer? -> exact-integer?\n (define/public (get-count destination start-time end-time)\n )))\n\n;; Your router% object will be instantiated and called as such:\n;; (define obj (new router% [memory-limit memory-limit]))\n;; (define param_1 (send obj add-packet source destination timestamp))\n;; (define param_2 (send obj forward-packet))\n;; (define param_3 (send obj get-count destination start-time end-time))",
"__typename": "CodeSnippetNode"
},
{
"lang": "Erlang",
"langSlug": "erlang",
"code": "-spec router_init_(MemoryLimit :: integer()) -> any().\nrouter_init_(MemoryLimit) ->\n .\n\n-spec router_add_packet(Source :: integer(), Destination :: integer(), Timestamp :: integer()) -> boolean().\nrouter_add_packet(Source, Destination, Timestamp) ->\n .\n\n-spec router_forward_packet() -> [integer()].\nrouter_forward_packet() ->\n .\n\n-spec router_get_count(Destination :: integer(), StartTime :: integer(), EndTime :: integer()) -> integer().\nrouter_get_count(Destination, StartTime, EndTime) ->\n .\n\n\n%% Your functions will be called as such:\n%% router_init_(MemoryLimit),\n%% Param_1 = router_add_packet(Source, Destination, Timestamp),\n%% Param_2 = router_forward_packet(),\n%% Param_3 = router_get_count(Destination, StartTime, EndTime),\n\n%% router_init_ will be called before every test case, in which you can do some necessary initializations.",
"__typename": "CodeSnippetNode"
},
{
"lang": "Elixir",
"langSlug": "elixir",
"code": "defmodule Router do\n @spec init_(memory_limit :: integer) :: any\n def init_(memory_limit) do\n \n end\n\n @spec add_packet(source :: integer, destination :: integer, timestamp :: integer) :: boolean\n def add_packet(source, destination, timestamp) do\n \n end\n\n @spec forward_packet() :: [integer]\n def forward_packet() do\n \n end\n\n @spec get_count(destination :: integer, start_time :: integer, end_time :: integer) :: integer\n def get_count(destination, start_time, end_time) do\n \n end\nend\n\n# Your functions will be called as such:\n# Router.init_(memory_limit)\n# param_1 = Router.add_packet(source, destination, timestamp)\n# param_2 = Router.forward_packet()\n# param_3 = Router.get_count(destination, start_time, end_time)\n\n# Router.init_ will be called before every test case, in which you can do some necessary initializations.",
"__typename": "CodeSnippetNode"
},
{
"lang": "Cangjie",
"langSlug": "cangjie",
"code": "class Router {\n init(memoryLimit: Int64) {\n\n }\n \n func addPacket(source: Int64, destination: Int64, timestamp: Int64): Bool {\n\n }\n \n func forwardPacket(): Array<Int64> {\n\n }\n \n func getCount(destination: Int64, startTime: Int64, endTime: Int64): Int64 {\n\n }\n}\n\n/**\n * Your Router object will be instantiated and called as such:\n * let obj: Router = Router(memoryLimit)\n * let param_1 = obj.addPacket(source,destination,timestamp)\n * let param_2 = obj.forwardPacket()\n * let param_3 = obj.getCount(destination,startTime,endTime)\n */",
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"1.7K\", \"totalSubmission\": \"7.5K\", \"totalAcceptedRaw\": 1742, \"totalSubmissionRaw\": 7458, \"acRate\": \"23.4%\"}",
"hints": [
"A deque can simulate the adding and forwarding of packets efficiently.",
"Use binary search for counting packets within a timestamp range."
],
"solution": null,
"status": null,
"sampleTestCase": "[\"Router\",\"addPacket\",\"addPacket\",\"addPacket\",\"addPacket\",\"addPacket\",\"forwardPacket\",\"addPacket\",\"getCount\"]\n[[3],[1,4,90],[2,5,90],[1,4,90],[3,5,95],[4,5,105],[],[5,2,110],[5,100,110]]",
"metaData": "{\n \"classname\": \"Router\",\n \"constructor\": {\n \"params\": [\n {\n \"name\": \"memoryLimit\",\n \"type\": \"integer\"\n }\n ]\n },\n \"methods\": [\n {\n \"params\": [\n {\n \"type\": \"integer\",\n \"name\": \"source\"\n },\n {\n \"type\": \"integer\",\n \"name\": \"destination\"\n },\n {\n \"type\": \"integer\",\n \"name\": \"timestamp\"\n }\n ],\n \"return\": {\n \"type\": \"boolean\"\n },\n \"name\": \"addPacket\"\n },\n {\n \"params\": [],\n \"name\": \"forwardPacket\",\n \"return\": {\n \"type\": \"integer[]\"\n }\n },\n {\n \"params\": [\n {\n \"type\": \"integer\",\n \"name\": \"destination\"\n },\n {\n \"type\": \"integer\",\n \"name\": \"startTime\"\n },\n {\n \"type\": \"integer\",\n \"name\": \"endTime\"\n }\n ],\n \"name\": \"getCount\",\n \"return\": {\n \"type\": \"integer\"\n }\n }\n ],\n \"return\": {\n \"type\": \"boolean\"\n },\n \"systemdesign\": true\n}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [],
"enableRunCode": true,
"envInfo": "{\"cpp\":[\"C++\",\"<p>\\u7248\\u672c\\uff1a<code>clang 19<\\/code> \\u91c7\\u7528\\u6700\\u65b0 C++ 23 \\u6807\\u51c6\\uff0c\\u5e76\\u4f7f\\u7528 GCC 14 \\u63d0\\u4f9b\\u7684 <code>libstdc++<\\/code>\\u3002<\\/p>\\r\\n\\r\\n<p>\\u7f16\\u8bd1\\u65f6\\uff0c\\u5c06\\u4f1a\\u91c7\\u7528 <code>-O2<\\/code> \\u7ea7\\u4f18\\u5316\\uff0c\\u5e76\\u63d0\\u4f9b <code>-gline-tables-only<\\/code> \\u53c2\\u6570\\u3002<a href=\\\"https:\\/\\/github.com\\/google\\/sanitizers\\/wiki\\/AddressSanitizer\\\" target=\\\"_blank\\\">AddressSanitizer<\\/a> \\u4e5f\\u88ab\\u5f00\\u542f\\u6765\\u68c0\\u6d4b <code>out-of-bounds<\\/code> \\u548c <code>use-after-free<\\/code> \\u9519\\u8bef\\u3002<\\/p>\\r\\n\\r\\n<p>\\u4e3a\\u4e86\\u4f7f\\u7528\\u65b9\\u4fbf\\uff0c\\u5927\\u90e8\\u5206\\u6807\\u51c6\\u5e93\\u7684\\u5934\\u6587\\u4ef6\\u5df2\\u7ecf\\u88ab\\u81ea\\u52a8\\u5bfc\\u5165\\u3002<\\/p>\"],\"java\":[\"Java\",\"<p>\\u7248\\u672c\\uff1a<code>OpenJDK 21<\\/code>\\u3002\\u4f7f\\u7528\\u7f16\\u8bd1\\u53c2\\u6570 <code>--enable-preview --release 21<\\/code><\\/p>\\r\\n\\r\\n<p>\\u4e3a\\u4e86\\u65b9\\u4fbf\\u8d77\\u89c1\\uff0c\\u5927\\u90e8\\u5206\\u6807\\u51c6\\u5e93\\u7684\\u5934\\u6587\\u4ef6\\u5df2\\u88ab\\u5bfc\\u5165\\u3002<\\/p>\\r\\n\\r\\n<p>\\u5305\\u542b Pair \\u7c7b: https:\\/\\/docs.oracle.com\\/javase\\/8\\/javafx\\/api\\/javafx\\/util\\/Pair.html <\\/p>\"],\"python\":[\"Python\",\"<p>\\u7248\\u672c\\uff1a <code>Python 2.7.18<\\/code><\\/p>\\r\\n\\r\\n<p>\\u4e3a\\u4e86\\u65b9\\u4fbf\\u8d77\\u89c1\\uff0c\\u5927\\u90e8\\u5206\\u5e38\\u7528\\u5e93\\u5df2\\u7ecf\\u88ab\\u81ea\\u52a8 \\u5bfc\\u5165\\uff0c\\u5982\\uff1a<a href=\\\"https:\\/\\/docs.python.org\\/2\\/library\\/array.html\\\" target=\\\"_blank\\\">array<\\/a>, <a href=\\\"https:\\/\\/docs.python.org\\/2\\/library\\/bisect.html\\\" target=\\\"_blank\\\">bisect<\\/a>, <a href=\\\"https:\\/\\/docs.python.org\\/2\\/library\\/collections.html\\\" target=\\\"_blank\\\">collections<\\/a>\\u3002\\u5982\\u679c\\u60a8\\u9700\\u8981\\u4f7f\\u7528\\u5176\\u4ed6\\u5e93\\u51fd\\u6570\\uff0c\\u8bf7\\u81ea\\u884c\\u5bfc\\u5165\\u3002<\\/p>\\r\\n\\r\\n<p>\\u6ce8\\u610f Python 2.7 <a href=\\\"https:\\/\\/www.python.org\\/dev\\/peps\\/pep-0373\\/\\\" target=\\\"_blank\\\">\\u5df2\\u4e0d\\u518d\\u7ef4\\u62a4<\\/a>\\u3002 \\u5982\\u60f3\\u4f7f\\u7528\\u6700\\u65b0\\u7248\\u7684Python\\uff0c\\u8bf7\\u9009\\u62e9Python 3\\u3002<\\/p>\"],\"c\":[\"C\",\"<p>\\u7248\\u672c\\uff1a<code>GCC 14<\\/code>\\uff0c\\u91c7\\u7528 GNU11 \\u6807\\u51c6\\u3002<\\/p>\\r\\n\\r\\n<p>\\u7f16\\u8bd1\\u65f6\\uff0c\\u5c06\\u4f1a\\u91c7\\u7528 <code>-O2<\\/code> \\u7ea7\\u4f18\\u5316\\uff0c\\u5e76\\u63d0\\u4f9b <code>-g1<\\/code> \\u53c2\\u6570\\u3002 <a href=\\\"https:\\/\\/github.com\\/google\\/sanitizers\\/wiki\\/AddressSanitizer\\\" target=\\\"_blank\\\">AddressSanitizer<\\/a> \\u4e5f\\u88ab\\u5f00\\u542f\\u6765\\u68c0\\u6d4b <code>out-of-bounds<\\/code> \\u548c <code>use-after-free<\\/code> \\u9519\\u8bef\\u3002<\\/p>\\r\\n\\r\\n<p>\\u4e3a\\u4e86\\u4f7f\\u7528\\u65b9\\u4fbf\\uff0c\\u5927\\u90e8\\u5206\\u6807\\u51c6\\u5e93\\u7684\\u5934\\u6587\\u4ef6\\u5df2\\u7ecf\\u88ab\\u81ea\\u52a8\\u5bfc\\u5165\\u3002<\\/p>\\r\\n\\r\\n<p>\\u5982\\u60f3\\u4f7f\\u7528\\u54c8\\u5e0c\\u8868\\u8fd0\\u7b97, \\u60a8\\u53ef\\u4ee5\\u4f7f\\u7528 <a href=\\\"https:\\/\\/troydhanson.github.io\\/uthash\\/\\\" target=\\\"_blank\\\">uthash<\\/a>\\u3002 \\\"uthash.h\\\"\\u5df2\\u7ecf\\u9ed8\\u8ba4\\u88ab\\u5bfc\\u5165\\u3002\\u8bf7\\u770b\\u5982\\u4e0b\\u793a\\u4f8b:<\\/p>\\r\\n\\r\\n<p><b>1. \\u5f80\\u54c8\\u5e0c\\u8868\\u4e2d\\u6dfb\\u52a0\\u4e00\\u4e2a\\u5bf9\\u8c61\\uff1a<\\/b>\\r\\n<pre>\\r\\nstruct hash_entry {\\r\\n int id; \\/* we'll use this field as the key *\\/\\r\\n char name[10];\\r\\n UT_hash_handle hh; \\/* makes this structure hashable *\\/\\r\\n};\\r\\n\\r\\nstruct hash_entry *users = NULL;\\r\\n\\r\\nvoid add_user(struct hash_entry *s) {\\r\\n HASH_ADD_INT(users, id, s);\\r\\n}\\r\\n<\\/pre>\\r\\n<\\/p>\\r\\n\\r\\n<p><b>2. \\u5728\\u54c8\\u5e0c\\u8868\\u4e2d\\u67e5\\u627e\\u4e00\\u4e2a\\u5bf9\\u8c61\\uff1a<\\/b>\\r\\n<pre>\\r\\nstruct hash_entry *find_user(int user_id) {\\r\\n struct hash_entry *s;\\r\\n HASH_FIND_INT(users, &user_id, s);\\r\\n return s;\\r\\n}\\r\\n<\\/pre>\\r\\n<\\/p>\\r\\n\\r\\n<p><b>3. \\u4ece\\u54c8\\u5e0c\\u8868\\u4e2d\\u5220\\u9664\\u4e00\\u4e2a\\u5bf9\\u8c61\\uff1a<\\/b>\\r\\n<pre>\\r\\nvoid delete_user(struct hash_entry *user) {\\r\\n HASH_DEL(users, user); \\r\\n}\\r\\n<\\/pre>\\r\\n<\\/p>\"],\"csharp\":[\"C#\",\"<p><a href=\\\"https:\\/\\/learn.microsoft.com\\/en-us\\/dotnet\\/csharp\\/whats-new\\/csharp-13\\\" target=\\\"_blank\\\">C# 13<\\/a> \\u8fd0\\u884c\\u5728 .NET 9 \\u4e0a<\\/p>\"],\"javascript\":[\"JavaScript\",\"<p>\\u7248\\u672c\\uff1a<code>Node.js 22.14.0<\\/code><\\/p>\\r\\n\\r\\n<p>\\u60a8\\u7684\\u4ee3\\u7801\\u5728\\u6267\\u884c\\u65f6\\u5c06\\u5e26\\u4e0a <code>--harmony<\\/code> \\u6807\\u8bb0\\u6765\\u5f00\\u542f <a href=\\\"http:\\/\\/node.green\\/\\\" target=\\\"_blank\\\">\\u65b0\\u7248ES6\\u7279\\u6027<\\/a>\\u3002<\\/p>\\r\\n\\r\\n<p><a href=\\\"https:\\/\\/lodash.com\\\" target=\\\"_blank\\\">lodash.js<\\/a> \\u5e93\\u5df2\\u7ecf\\u9ed8\\u8ba4\\u88ab\\u5305\\u542b\\u3002<\\/p>\\r\\n\\r\\n<p> \\u5982\\u9700\\u4f7f\\u7528\\u961f\\u5217\\/\\u4f18\\u5148\\u961f\\u5217\\uff0c\\u60a8\\u53ef\\u4f7f\\u7528 <a href=\\\"https:\\/\\/github.com\\/datastructures-js\\/priority-queue\\/tree\\/v6.3.2\\\" target=\\\"_blank\\\"> datastructures-js\\/priority-queue@6.3.2<\\/a>\\uff0c<a href=\\\"https:\\/\\/github.com\\/datastructures-js\\/queue\\/tree\\/v4.2.3\\\" target=\\\"_blank\\\"> datastructures-js\\/queue@4.2.3<\\/a> \\u4ee5\\u53ca <a href=\\\"https:\\/\\/github.com\\/datastructures-js\\/deque\\/tree\\/v1.0.4\\\" target=\\\"_blank\\\"> datastructures-js\\/deque@1.0.4<\\/a>\\u3002<\\/p>\"],\"ruby\":[\"Ruby\",\"<p>\\u4f7f\\u7528 <code>Ruby 3.2<\\/code> \\u6267\\u884c<\\/p>\\r\\n\\r\\n<p>\\u4e00\\u4e9b\\u5e38\\u7528\\u7684\\u6570\\u636e\\u7ed3\\u6784\\u5df2\\u5728 Algorithms \\u6a21\\u5757\\u4e2d\\u63d0\\u4f9b\\uff1ahttps:\\/\\/www.rubydoc.info\\/github\\/kanwei\\/algorithms\\/Algorithms<\\/p>\"],\"swift\":[\"Swift\",\"<p>\\u7248\\u672c\\uff1a<code>Swift 6.0<\\/code><\\/p>\\r\\n\\r\\n<p>\\u60a8\\u53ef\\u4ee5\\u4f7f\\u7528 <a href=\\\"https:\\/\\/github.com\\/apple\\/swift-algorithms\\/tree\\/1.2.0\\\" target=\\\"_blank\\\">swift-algorithms 1.2.0<\\/a>\\uff0c<a href=\\\"https:\\/\\/github.com\\/apple\\/swift-collections\\/tree\\/1.1.4\\\" target=\\\"_blank\\\">swift-collections 1.1.4<\\/a> \\u548c <a href=\\\"https:\\/\\/github.com\\/apple\\/swift-numerics\\/tree\\/1.0.2\\\" target=\\\"_blank\\\">swift-numerics 1.0.2<\\/a><\\/p>\\r\\n\\r\\n<p>\\u6211\\u4eec\\u901a\\u5e38\\u4fdd\\u8bc1\\u66f4\\u65b0\\u5230 <a href=\\\"https:\\/\\/swift.org\\/download\\/\\\" target=\\\"_blank\\\">Apple\\u653e\\u51fa\\u7684\\u6700\\u65b0\\u7248Swift<\\/a>\\u3002\\u5982\\u679c\\u60a8\\u53d1\\u73b0Swift\\u4e0d\\u662f\\u6700\\u65b0\\u7248\\u7684\\uff0c\\u8bf7\\u8054\\u7cfb\\u6211\\u4eec\\uff01\\u6211\\u4eec\\u5c06\\u5c3d\\u5feb\\u66f4\\u65b0\\u3002<\\/p>\"],\"golang\":[\"Go\",\"<p>\\u7248\\u672c\\uff1a<code>Go 1.23<\\/code><\\/p>\\r\\n\\r\\n<p>\\u652f\\u6301 <a href=\\\"https:\\/\\/pkg.go.dev\\/github.com\\/emirpasic\\/gods@v1.18.1\\\" target=\\\"_blank\\\">https:\\/\\/pkg.go.dev\\/github.com\\/emirpasic\\/gods@v1.18.1<\\/a> \\u548c <a href=\\\"https:\\/\\/pkg.go.dev\\/github.com\\/emirpasic\\/gods\\/v2@v2.0.0-alpha\\\" target=\\\"_blank\\\">https:\\/\\/pkg.go.dev\\/github.com\\/emirpasic\\/gods\\/v2@v2.0.0-alpha<\\/a> \\u7b2c\\u4e09\\u65b9\\u5e93\\u3002<\\/p>\"],\"python3\":[\"Python3\",\"<p>\\u7248\\u672c\\uff1a<code>Python 3.11<\\/code><\\/p>\\r\\n\\r\\n<p>\\u4e3a\\u4e86\\u65b9\\u4fbf\\u8d77\\u89c1\\uff0c\\u5927\\u90e8\\u5206\\u5e38\\u7528\\u5e93\\u5df2\\u7ecf\\u88ab\\u81ea\\u52a8 \\u5bfc\\u5165\\uff0c\\u5982<a href=\\\"https:\\/\\/docs.python.org\\/3\\/library\\/array.html\\\" target=\\\"_blank\\\">array<\\/a>, <a href=\\\"https:\\/\\/docs.python.org\\/3\\/library\\/bisect.html\\\" target=\\\"_blank\\\">bisect<\\/a>, <a href=\\\"https:\\/\\/docs.python.org\\/3\\/library\\/collections.html\\\" target=\\\"_blank\\\">collections<\\/a>\\u3002 \\u5982\\u679c\\u60a8\\u9700\\u8981\\u4f7f\\u7528\\u5176\\u4ed6\\u5e93\\u51fd\\u6570\\uff0c\\u8bf7\\u81ea\\u884c\\u5bfc\\u5165\\u3002<\\/p>\\r\\n\\r\\n<p>\\u5982\\u9700\\u4f7f\\u7528 Map\\/TreeMap \\u6570\\u636e\\u7ed3\\u6784\\uff0c\\u60a8\\u53ef\\u4f7f\\u7528 <a href=\\\"http:\\/\\/www.grantjenks.com\\/docs\\/sortedcontainers\\/\\\" target=\\\"_blank\\\">sortedcontainers<\\/a> \\u5e93\\u3002<\\/p>\"],\"scala\":[\"Scala\",\"<p>\\u7248\\u672c\\uff1a<code>Scala 3.3.1<\\/code><\\/p>\"],\"kotlin\":[\"Kotlin\",\"<p>\\u7248\\u672c\\uff1a<code>Kotlin 2.1.10<\\/code><\\/p>\"],\"rust\":[\"Rust\",\"<p>\\u7248\\u672c\\uff1a<code>rust 1.85.0<\\/code><\\/p>\\r\\n\\r\\n<p>\\u652f\\u6301 crates.io \\u7684 <a href=\\\"https:\\/\\/crates.io\\/crates\\/rand\\\" target=\\\"_blank\\\">rand<\\/a>\\u3001<a href=\\\"https:\\/\\/crates.io\\/crates\\/regex\\\" target=\\\"_blank\\\">regex<\\/a> \\u548c <a href=\\\"https:\\/\\/crates.io\\/crates\\/itertools\\\" target=\\\"_blank\\\">itertools<\\/a><\\/p>\"],\"php\":[\"PHP\",\"<p><code>PHP 8.2<\\/code>.<\\/p>\\r\\n\\r\\n<p>With bcmath module.<\\/p>\"],\"typescript\":[\"TypeScript\",\"<p>TypeScript 5.7.3<\\/p>\\r\\n\\r\\n<p>Compile Options: --alwaysStrict --strictBindCallApply --strictFunctionTypes --target ES2024<\\/p>\\r\\n\\r\\n<p><a href=\\\"https:\\/\\/lodash.com\\\" target=\\\"_blank\\\">lodash.js<\\/a> \\u5e93\\u5df2\\u7ecf\\u9ed8\\u8ba4\\u88ab\\u5305\\u542b\\u3002<\\/p>\\r\\n\\r\\n<p> \\u5982\\u9700\\u4f7f\\u7528\\u961f\\u5217\\/\\u4f18\\u5148\\u961f\\u5217\\uff0c\\u60a8\\u53ef\\u4f7f\\u7528 <a href=\\\"https:\\/\\/github.com\\/datastructures-js\\/priority-queue\\/tree\\/v6.3.2\\\" target=\\\"_blank\\\"> datastructures-js\\/priority-queue@6.3.2<\\/a>\\uff0c<a href=\\\"https:\\/\\/github.com\\/datastructures-js\\/queue\\/tree\\/v4.2.3\\\" target=\\\"_blank\\\"> datastructures-js\\/queue@4.2.3<\\/a> \\u4ee5\\u53ca <a href=\\\"https:\\/\\/github.com\\/datastructures-js\\/deque\\/tree\\/v1.0.4\\\" target=\\\"_blank\\\"> datastructures-js\\/deque@1.0.4<\\/a>\\u3002<\\/p>\"],\"racket\":[\"Racket\",\"<p><a href=\\\"https:\\/\\/docs.racket-lang.org\\/guide\\/performance.html#%28tech._c%29\\\" target=\\\"_blank\\\">Racket CS<\\/a> v8.15<\\/p>\\r\\n\\r\\n<p>\\u4f7f\\u7528 #lang racket<\\/p>\\r\\n\\r\\n<p>\\u5df2\\u9884\\u5148 (require data\\/gvector data\\/queue data\\/order data\\/heap). \\u82e5\\u9700\\u4f7f\\u7528\\u5176\\u5b83\\u6570\\u636e\\u7ed3\\u6784\\uff0c\\u53ef\\u81ea\\u884c require\\u3002<\\/p>\"],\"erlang\":[\"Erlang\",\"Erlang\\/OTP 26\"],\"elixir\":[\"Elixir\",\"Elixir 1.17 with Erlang\\/OTP 26\"],\"dart\":[\"Dart\",\"<p>Dart 3.2\\u3002\\u60a8\\u53ef\\u4ee5\\u4f7f\\u7528 <a href=\\\"https:\\/\\/pub.dev\\/packages\\/collection\\/versions\\/1.18.0\\\" target=\\\"_blank\\\">collection<\\/a> \\u5305<\\/p>\\r\\n\\r\\n<p>\\u60a8\\u7684\\u4ee3\\u7801\\u5c06\\u4f1a\\u88ab\\u4e0d\\u7f16\\u8bd1\\u76f4\\u63a5\\u8fd0\\u884c<\\/p>\"],\"cangjie\":[\"Cangjie\",\"<p>\\u7248\\u672c\\uff1a0.53.11 (cjnative)<\\/p>\\r\\n\\r\\n<p>\\u7f16\\u8bd1\\u53c2\\u6570\\uff1a<code>-O2 --disable-reflection<\\/code><\\/p>\\r\\n\\r\\n<p>\\u5feb\\u901f\\u5165\\u95e8\\u8bf7\\u67e5\\u9605<a href=\\\"https:\\/\\/leetcode.cn\\/leetbook\\/detail\\/cangjie\\/\\\" target=\\\"_blank\\\">\\u300c\\u4ed3\\u9889\\u7f16\\u7a0b\\u8bed\\u8a00\\u5f00\\u53d1\\u6307\\u5357\\u300d<\\/a><\\/p>\"]}",
"book": null,
"isSubscribed": false,
"isDailyQuestion": false,
"dailyRecordStatus": null,
"editorType": "CKEDITOR",
"ugcQuestionId": null,
"style": "LEETCODE",
"exampleTestcases": "[\"Router\",\"addPacket\",\"addPacket\",\"addPacket\",\"addPacket\",\"addPacket\",\"forwardPacket\",\"addPacket\",\"getCount\"]\n[[3],[1,4,90],[2,5,90],[1,4,90],[3,5,95],[4,5,105],[],[5,2,110],[5,100,110]]\n[\"Router\",\"addPacket\",\"forwardPacket\",\"forwardPacket\"]\n[[2],[7,4,90],[],[]]",
"__typename": "QuestionNode"
}
}
}