Implement Router
<p>Design a data structure that can efficiently manage data packets in a network router. Each data packet consists of the following attributes:</p>

<ul>
	<li><code>source</code>: A unique identifier for the machine that generated the packet.</li>
	<li><code>destination</code>: A unique identifier for the target machine.</li>
	<li><code>timestamp</code>: The time at which the packet arrived at the router.</li>
</ul>

<p>Implement the <code>Router</code> class:</p>

<p><code>Router(int memoryLimit)</code>: Initializes the Router object with a fixed memory limit.</p>

<ul>
	<li><code>memoryLimit</code> is the <strong>maximum</strong> number of packets the router can store at any given time.</li>
	<li>If adding a new packet would exceed this limit, the <strong>oldest</strong> packet must be removed to free up space.</li>
</ul>

<p><code>bool addPacket(int source, int destination, int timestamp)</code>: Adds a packet with the given attributes to the router.</p>

<ul>
	<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>
	<li>Return <code>true</code> if the packet is successfully added (i.e., it is not a duplicate); otherwise return <code>false</code>.</li>
</ul>

<p><code>int[] forwardPacket()</code>: Forwards the next packet in FIFO (First In First Out) order.</p>

<ul>
	<li>Remove the packet from storage.</li>
	<li>Return the packet as an array <code>[source, destination, timestamp]</code>.</li>
	<li>If there are no packets to forward, return an empty array.</li>
</ul>

<p><code>int getCount(int destination, int startTime, int endTime)</code>:</p>

<ul>
	<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>
</ul>

<p><strong>Note</strong> that queries for <code>addPacket</code> will be made in increasing order of <code>timestamp</code>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<div class="example-block">
<p><strong>Input:</strong><br />
<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 />
[[3], [1, 4, 90], [2, 5, 90], [1, 4, 90], [3, 5, 95], [4, 5, 105], [], [5, 2, 110], [5, 100, 110]]</span></p>

<p><strong>Output:</strong><br />
<span class="example-io">[null, true, true, false, true, true, [2, 5, 90], true, 1] </span></p>

<p><strong>Explanation</strong></p>
Router router = new Router(3); // Initialize Router with memoryLimit of 3.<br />
router.addPacket(1, 4, 90); // Packet is added. Return True.<br />
router.addPacket(2, 5, 90); // Packet is added. Return True.<br />
router.addPacket(1, 4, 90); // This is a duplicate packet. Return False.<br />
router.addPacket(3, 5, 95); // Packet is added. Return True<br />
router.addPacket(4, 5, 105); // Packet is added, <code>[1, 4, 90]</code> is removed as number of packets exceeds memoryLimit. Return True.<br />
router.forwardPacket(); // Return <code>[2, 5, 90]</code> and remove it from router.<br />
router.addPacket(5, 2, 110); // Packet is added. Return True.<br />
router.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>

<p><strong class="example">Example 2:</strong></p>

<div class="example-block">
<p><strong>Input:</strong><br />
<span class="example-io">[&quot;Router&quot;, &quot;addPacket&quot;, &quot;forwardPacket&quot;, &quot;forwardPacket&quot;]<br />
[[2], [7, 4, 90], [], []]</span></p>

<p><strong>Output:</strong><br />
<span class="example-io">[null, true, [7, 4, 90], []] </span></p>

<p><strong>Explanation</strong></p>
Router router = new Router(2); // Initialize <code>Router</code> with <code>memoryLimit</code> of 2.<br />
router.addPacket(7, 4, 90); // Return True.<br />
router.forwardPacket(); // Return <code>[7, 4, 90]</code>.<br />
router.forwardPacket(); // There are no packets left, return <code>[]</code>.</div>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>2 &lt;= memoryLimit &lt;= 10<sup>5</sup></code></li>
	<li><code>1 &lt;= source, destination &lt;= 2 * 10<sup>5</sup></code></li>
	<li><code>1 &lt;= timestamp &lt;= 10<sup>9</sup></code></li>
	<li><code>1 &lt;= startTime &lt;= endTime &lt;= 10<sup>9</sup></code></li>
	<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>
	<li>queries for <code>addPacket</code> will be made in increasing order of <code>timestamp</code>.</li>
</ul>

[]
[]
[{"value": "cpp", "text": "C++", "defaultCode": "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 */"}, {"value": "java", "text": "Java", "defaultCode": "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 */"}, {"value": "python", "text": "Python", "defaultCode": "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)"}, {"value": "python3", "text": "Python3", "defaultCode": "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)"}, {"value": "c", "text": "C", "defaultCode": "\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*/"}, {"value": "csharp", "text": "C#", "defaultCode": "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 */"}, {"value": "javascript", "text": "JavaScript", "defaultCode": "/**\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 */"}, {"value": "typescript", "text": "TypeScript", "defaultCode": "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 */"}, {"value": "php", "text": "PHP", "defaultCode": "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 */"}, {"value": "swift", "text": "Swift", "defaultCode": "\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 */"}, {"value": "kotlin", "text": "Kotlin", "defaultCode": "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 */"}, {"value": "dart", "text": "Dart", "defaultCode": "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 */"}, {"value": "golang", "text": "Go", "defaultCode": "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 */"}, {"value": "ruby", "text": "Ruby", "defaultCode": "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)"}, {"value": "scala", "text": "Scala", "defaultCode": "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 */"}, {"value": "rust", "text": "Rust", "defaultCode": "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 */"}, {"value": "racket", "text": "Racket", "defaultCode": "(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))"}, {"value": "erlang", "text": "Erlang", "defaultCode": "-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."}, {"value": "elixir", "text": "Elixir", "defaultCode": "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."}]
{
  "classname": "Router",
  "constructor": {
    "params": [
      {
        "name": "memoryLimit",
        "type": "integer"
      }
    ]
  },
  "methods": [
    {
      "params": [
        {
          "type": "integer",
          "name": "source"
        },
        {
          "type": "integer",
          "name": "destination"
        },
        {
          "type": "integer",
          "name": "timestamp"
        }
      ],
      "return": {
        "type": "boolean"
      },
      "name": "addPacket"
    },
    {
      "params": [],
      "name": "forwardPacket",
      "return": {
        "type": "integer[]"
      }
    },
    {
      "params": [
        {
          "type": "integer",
          "name": "destination"
        },
        {
          "type": "integer",
          "name": "startTime"
        },
        {
          "type": "integer",
          "name": "endTime"
        }
      ],
      "name": "getCount",
      "return": {
        "type": "integer"
      }
    }
  ],
  "return": {
    "type": "boolean"
  },
  "systemdesign": true
}
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressSanitizer</a> is also enabled to help detect out-of-bounds and use-after-free bugs.</p>\r\n\r\n<p>Most standard library headers are already included automatically for your convenience.</p>"], "java": ["Java", "<p><code>OpenJDK 21</code>. Using compile arguments: <code>--enable-preview --release 21</code></p>\r\n\r\n<p>Most standard library headers are already included automatically for your convenience.</p>\r\n<p>Includes <code>Pair</code> class from https://docs.oracle.com/javase/8/javafx/api/javafx/util/Pair.html.</p>"], "python": ["Python", "<p><code>Python 2.7.18</code>.</p>\r\n\r\n<p>Most libraries are already imported automatically for your convenience, such as <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>. If you need more libraries, you can import it yourself.</p>\r\n\r\n<p>For Map/TreeMap data structure, you may use <a href=\"http://www.grantjenks.com/docs/sortedcontainers/\" target=\"_blank\">sortedcontainers</a> library.</p>\r\n\r\n<p>Note that Python 2.7 <a href=\"https://www.python.org/dev/peps/pep-0373/\" target=\"_blank\">is not maintained anymore</a>. For the latest Python, please choose Python3 instead.</p>"], "c": ["C", "<p>Compiled with <code>gcc 14</code> using the gnu11 standard.</p>\r\n\r\n<p>Your code is compiled with level one optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressSanitizer</a> is also enabled to help detect out-of-bounds and use-after-free bugs.</p>\r\n\r\n<p>Most standard library headers are already included automatically for your convenience.</p>\r\n\r\n<p>For hash table operations, you may use <a href=\"https://troydhanson.github.io/uthash/\" target=\"_blank\">uthash</a>. \"uthash.h\" is included by default. Below are some examples:</p>\r\n\r\n<p><b>1. Adding an item to a hash.</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. Looking up an item in a hash:</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. Deleting an item in a hash:</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> with .NET 9 runtime</p>"], "javascript": ["JavaScript", "<p><code>Node.js 22.14.0</code>.</p>\r\n\r\n<p>Your code is run with <code>--harmony</code> flag, enabling <a href=\"http://node.green/\" target=\"_blank\">new ES6 features</a>.</p>\r\n\r\n<p><a href=\"https://lodash.com\" target=\"_blank\">lodash.js</a> library is included by default.</p>\r\n\r\n<p>For Priority Queue / Queue data structures, you may use 6.3.2 version of <a href=\"https://github.com/datastructures-js/priority-queue/tree/v6.3.2\" target=\"_blank\">datastructures-js/priority-queue</a> and 4.2.3 version of <a href=\"https://github.com/datastructures-js/queue/tree/v4.2.3\" target=\"_blank\">datastructures-js/queue</a> and 1.0.4 version of <a href=\"https://github.com/datastructures-js/deque/tree/v1.0.4\" target=\"_blank\">datastructures-js/deque</a>.</p>"], "ruby": ["Ruby", "<p><code>Ruby 3.2</code></p>\r\n\r\n<p>Some common data structure implementations are provided in the Algorithms module: https://www.rubydoc.info/github/kanwei/algorithms/Algorithms</p>"], "swift": ["Swift", "<p><code>Swift 6.0</code>.</p>\r\n\r\n<p>You may use the following packages:<br/>\r\n<a href=\"https://github.com/apple/swift-algorithms/tree/1.2.0\" target=\"_blank\">swift-algorithms 1.2.0</a><br/>\r\n<a href=\"https://github.com/apple/swift-collections/tree/1.1.4\" target=\"_blank\">swift-collections 1.1.4</a><br/>\r\n<a href=\"https://github.com/apple/swift-numerics/tree/1.0.2\" target=\"_blank\">swift-numerics 1.0.2</a></p>"], "golang": ["Go", "<p><code>Go 1.23</code></p>\r\n<p>Support <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> and <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> library.</p>"], "python3": ["Python3", "<p><code>Python 3.11</code>.</p>\r\n\r\n<p>Most libraries are already imported automatically for your convenience, such as <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>. If you need more libraries, you can import it yourself.</p>\r\n\r\n<p>For Map/TreeMap data structure, you may use <a href=\"http://www.grantjenks.com/docs/sortedcontainers/\" target=\"_blank\">sortedcontainers</a> library.</p>"], "scala": ["Scala", "<p><code>Scala 3.3.1</code>.</p>"], "kotlin": ["Kotlin", "<p><code>Kotlin 2.1.10</code>.</p>"], "rust": ["Rust", "<p><code>Rust 1.85.0</code>. Your code will be compiled with <code>opt-level</code> 2.</p>\r\n\r\n<p>Supports <a href=\"https://crates.io/crates/rand\" target=\"_blank\">rand v0.8</a> and <a href=\"https://crates.io/crates/regex\" target=\"_blank\">regex\u00a0v1</a> and <a href=\"https://crates.io/crates/itertools\" target=\"_blank\">itertools\u00a0v0.14</a> from crates.io</p>"], "php": ["PHP", "<p><code>PHP 8.2</code>.</p>\r\n<p>With bcmath module</p>"], "typescript": ["Typescript", "<p><code>TypeScript 5.7.3, Node.js 22.14.0</code>.</p>\r\n\r\n<p>Compile Options: <code>--alwaysStrict --strictBindCallApply --strictFunctionTypes --target ES2024</code></p>\r\n\r\n<p><a href=\"https://lodash.com\" target=\"_blank\">lodash.js</a> library is included by default.</p>\r\n\r\n<p>For Priority Queue / Queue data structures, you may use 6.3.2 version of <a href=\"https://github.com/datastructures-js/priority-queue/tree/v6.3.2\" target=\"_blank\">datastructures-js/priority-queue</a> and 4.2.3 version of <a href=\"https://github.com/datastructures-js/queue/tree/v4.2.3\" target=\"_blank\">datastructures-js/queue</a> and 1.0.4 version of <a href=\"https://github.com/datastructures-js/deque/tree/v1.0.4\" target=\"_blank\">datastructures-js/deque</a>.</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>Using <code>#lang racket</code></p>\r\n\r\n<p>Required <code>data/gvector data/queue data/order data/heap</code> automatically for your convenience</p>"], "erlang": ["Erlang", "Erlang/OTP 26"], "elixir": ["Elixir", "Elixir 1.17 with Erlang/OTP 26"], "dart": ["Dart", "<p>Dart 3.2. You may use package <a href=\"https://pub.dev/packages/collection/versions/1.18.0\" target=\"_blank\">collection</a></p>\r\n\r\n<p>Your code will be run directly without compiling</p>"]}
['Array', 'Hash Table', 'Binary Search', 'Design', 'Queue', 'Ordered Set']