{ "data": { "question": { "questionId": "3797", "questionFrontendId": "3484", "categoryTitle": "Algorithms", "boundTopicId": 3612464, "title": "Design Spreadsheet", "titleSlug": "design-spreadsheet", "content": "

A spreadsheet is a grid with 26 columns (labeled from 'A' to 'Z') and a given number of rows. Each cell in the spreadsheet can hold an integer value between 0 and 105.

\n\n

Implement the Spreadsheet class:

\n\n\n\n

Note: If getValue references a cell that has not been explicitly set using setCell, its value is considered 0.

\n\n

 

\n

Example 1:

\n\n
\n

Input:
\n["Spreadsheet", "getValue", "setCell", "getValue", "setCell", "getValue", "resetCell", "getValue"]
\n[[3], ["=5+7"], ["A1", 10], ["=A1+6"], ["B2", 15], ["=A1+B2"], ["A1"], ["=A1+B2"]]

\n\n

Output:
\n[null, 12, null, 16, null, 25, null, 15]

\n\n

Explanation

\nSpreadsheet spreadsheet = new Spreadsheet(3); // Initializes a spreadsheet with 3 rows and 26 columns
\nspreadsheet.getValue("=5+7"); // returns 12 (5+7)
\nspreadsheet.setCell("A1", 10); // sets A1 to 10
\nspreadsheet.getValue("=A1+6"); // returns 16 (10+6)
\nspreadsheet.setCell("B2", 15); // sets B2 to 15
\nspreadsheet.getValue("=A1+B2"); // returns 25 (10+15)
\nspreadsheet.resetCell("A1"); // resets A1 to 0
\nspreadsheet.getValue("=A1+B2"); // returns 15 (0+15)
\n\n

 

\n

Constraints:

\n\n\n", "translatedTitle": "设计电子表格", "translatedContent": "

电子表格是一个网格,它有 26 列(从 'A''Z')和指定数量的 rows。每个单元格可以存储一个 0 到 105 之间的整数值。

\n\n

请你实现一个 Spreadsheet 类:

\n\n\n\n

注意: 如果 getValue 引用一个未通过 setCell 明确设置的单元格,则该单元格的值默认为 0 。

\n\n

 

\n\n

示例 1:

\n\n
\n

输入:
\n[\"Spreadsheet\", \"getValue\", \"setCell\", \"getValue\", \"setCell\", \"getValue\", \"resetCell\", \"getValue\"]
\n[[3], [\"=5+7\"], [\"A1\", 10], [\"=A1+6\"], [\"B2\", 15], [\"=A1+B2\"], [\"A1\"], [\"=A1+B2\"]]

\n\n

输出:
\n[null, 12, null, 16, null, 25, null, 15]

\n\n

解释

\nSpreadsheet spreadsheet = new Spreadsheet(3); // 初始化一个具有 3 行和 26 列的电子表格
\nspreadsheet.getValue(\"=5+7\"); // 返回 12 (5+7)
\nspreadsheet.setCell(\"A1\", 10); // 设置 A1 为 10
\nspreadsheet.getValue(\"=A1+6\"); // 返回 16 (10+6)
\nspreadsheet.setCell(\"B2\", 15); // 设置 B2 为 15
\nspreadsheet.getValue(\"=A1+B2\"); // 返回 25 (10+15)
\nspreadsheet.resetCell(\"A1\"); // 重置 A1 为 0
\nspreadsheet.getValue(\"=A1+B2\"); // 返回 15 (0+15)
\n\n

 

\n\n

提示:

\n\n\n", "isPaidOnly": false, "difficulty": "Medium", "likes": 2, "dislikes": 0, "isLiked": null, "similarQuestions": "[{\"title\": \"Excel Sheet Column Title\", \"titleSlug\": \"excel-sheet-column-title\", \"difficulty\": \"Easy\", \"translatedTitle\": \"Excel \\u8868\\u5217\\u540d\\u79f0\", \"isPaidOnly\": false}]", "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": "Array", "slug": "array", "translatedName": "数组", "__typename": "TopicTagNode" }, { "name": "Hash Table", "slug": "hash-table", "translatedName": "哈希表", "__typename": "TopicTagNode" }, { "name": "String", "slug": "string", "translatedName": "字符串", "__typename": "TopicTagNode" }, { "name": "Matrix", "slug": "matrix", "translatedName": "矩阵", "__typename": "TopicTagNode" } ], "companyTagStats": null, "codeSnippets": [ { "lang": "C++", "langSlug": "cpp", "code": "class Spreadsheet {\npublic:\n Spreadsheet(int rows) {\n \n }\n \n void setCell(string cell, int value) {\n \n }\n \n void resetCell(string cell) {\n \n }\n \n int getValue(string formula) {\n \n }\n};\n\n/**\n * Your Spreadsheet object will be instantiated and called as such:\n * Spreadsheet* obj = new Spreadsheet(rows);\n * obj->setCell(cell,value);\n * obj->resetCell(cell);\n * int param_3 = obj->getValue(formula);\n */", "__typename": "CodeSnippetNode" }, { "lang": "Java", "langSlug": "java", "code": "class Spreadsheet {\n\n public Spreadsheet(int rows) {\n \n }\n \n public void setCell(String cell, int value) {\n \n }\n \n public void resetCell(String cell) {\n \n }\n \n public int getValue(String formula) {\n \n }\n}\n\n/**\n * Your Spreadsheet object will be instantiated and called as such:\n * Spreadsheet obj = new Spreadsheet(rows);\n * obj.setCell(cell,value);\n * obj.resetCell(cell);\n * int param_3 = obj.getValue(formula);\n */", "__typename": "CodeSnippetNode" }, { "lang": "Python", "langSlug": "python", "code": "class Spreadsheet(object):\n\n def __init__(self, rows):\n \"\"\"\n :type rows: int\n \"\"\"\n \n\n def setCell(self, cell, value):\n \"\"\"\n :type cell: str\n :type value: int\n :rtype: None\n \"\"\"\n \n\n def resetCell(self, cell):\n \"\"\"\n :type cell: str\n :rtype: None\n \"\"\"\n \n\n def getValue(self, formula):\n \"\"\"\n :type formula: str\n :rtype: int\n \"\"\"\n \n\n\n# Your Spreadsheet object will be instantiated and called as such:\n# obj = Spreadsheet(rows)\n# obj.setCell(cell,value)\n# obj.resetCell(cell)\n# param_3 = obj.getValue(formula)", "__typename": "CodeSnippetNode" }, { "lang": "Python3", "langSlug": "python3", "code": "class Spreadsheet:\n\n def __init__(self, rows: int):\n \n\n def setCell(self, cell: str, value: int) -> None:\n \n\n def resetCell(self, cell: str) -> None:\n \n\n def getValue(self, formula: str) -> int:\n \n\n\n# Your Spreadsheet object will be instantiated and called as such:\n# obj = Spreadsheet(rows)\n# obj.setCell(cell,value)\n# obj.resetCell(cell)\n# param_3 = obj.getValue(formula)", "__typename": "CodeSnippetNode" }, { "lang": "C", "langSlug": "c", "code": "\n\n\ntypedef struct {\n \n} Spreadsheet;\n\n\nSpreadsheet* spreadsheetCreate(int rows) {\n \n}\n\nvoid spreadsheetSetCell(Spreadsheet* obj, char* cell, int value) {\n \n}\n\nvoid spreadsheetResetCell(Spreadsheet* obj, char* cell) {\n \n}\n\nint spreadsheetGetValue(Spreadsheet* obj, char* formula) {\n \n}\n\nvoid spreadsheetFree(Spreadsheet* obj) {\n \n}\n\n/**\n * Your Spreadsheet struct will be instantiated and called as such:\n * Spreadsheet* obj = spreadsheetCreate(rows);\n * spreadsheetSetCell(obj, cell, value);\n \n * spreadsheetResetCell(obj, cell);\n \n * int param_3 = spreadsheetGetValue(obj, formula);\n \n * spreadsheetFree(obj);\n*/", "__typename": "CodeSnippetNode" }, { "lang": "C#", "langSlug": "csharp", "code": "public class Spreadsheet {\n\n public Spreadsheet(int rows) {\n \n }\n \n public void SetCell(string cell, int value) {\n \n }\n \n public void ResetCell(string cell) {\n \n }\n \n public int GetValue(string formula) {\n \n }\n}\n\n/**\n * Your Spreadsheet object will be instantiated and called as such:\n * Spreadsheet obj = new Spreadsheet(rows);\n * obj.SetCell(cell,value);\n * obj.ResetCell(cell);\n * int param_3 = obj.GetValue(formula);\n */", "__typename": "CodeSnippetNode" }, { "lang": "JavaScript", "langSlug": "javascript", "code": "/**\n * @param {number} rows\n */\nvar Spreadsheet = function(rows) {\n \n};\n\n/** \n * @param {string} cell \n * @param {number} value\n * @return {void}\n */\nSpreadsheet.prototype.setCell = function(cell, value) {\n \n};\n\n/** \n * @param {string} cell\n * @return {void}\n */\nSpreadsheet.prototype.resetCell = function(cell) {\n \n};\n\n/** \n * @param {string} formula\n * @return {number}\n */\nSpreadsheet.prototype.getValue = function(formula) {\n \n};\n\n/** \n * Your Spreadsheet object will be instantiated and called as such:\n * var obj = new Spreadsheet(rows)\n * obj.setCell(cell,value)\n * obj.resetCell(cell)\n * var param_3 = obj.getValue(formula)\n */", "__typename": "CodeSnippetNode" }, { "lang": "TypeScript", "langSlug": "typescript", "code": "class Spreadsheet {\n constructor(rows: number) {\n \n }\n\n setCell(cell: string, value: number): void {\n \n }\n\n resetCell(cell: string): void {\n \n }\n\n getValue(formula: string): number {\n \n }\n}\n\n/**\n * Your Spreadsheet object will be instantiated and called as such:\n * var obj = new Spreadsheet(rows)\n * obj.setCell(cell,value)\n * obj.resetCell(cell)\n * var param_3 = obj.getValue(formula)\n */", "__typename": "CodeSnippetNode" }, { "lang": "PHP", "langSlug": "php", "code": "class Spreadsheet {\n /**\n * @param Integer $rows\n */\n function __construct($rows) {\n \n }\n \n /**\n * @param String $cell\n * @param Integer $value\n * @return NULL\n */\n function setCell($cell, $value) {\n \n }\n \n /**\n * @param String $cell\n * @return NULL\n */\n function resetCell($cell) {\n \n }\n \n /**\n * @param String $formula\n * @return Integer\n */\n function getValue($formula) {\n \n }\n}\n\n/**\n * Your Spreadsheet object will be instantiated and called as such:\n * $obj = Spreadsheet($rows);\n * $obj->setCell($cell, $value);\n * $obj->resetCell($cell);\n * $ret_3 = $obj->getValue($formula);\n */", "__typename": "CodeSnippetNode" }, { "lang": "Swift", "langSlug": "swift", "code": "\nclass Spreadsheet {\n\n init(_ rows: Int) {\n \n }\n \n func setCell(_ cell: String, _ value: Int) {\n \n }\n \n func resetCell(_ cell: String) {\n \n }\n \n func getValue(_ formula: String) -> Int {\n \n }\n}\n\n/**\n * Your Spreadsheet object will be instantiated and called as such:\n * let obj = Spreadsheet(rows)\n * obj.setCell(cell, value)\n * obj.resetCell(cell)\n * let ret_3: Int = obj.getValue(formula)\n */", "__typename": "CodeSnippetNode" }, { "lang": "Kotlin", "langSlug": "kotlin", "code": "class Spreadsheet(rows: Int) {\n\n fun setCell(cell: String, value: Int) {\n \n }\n\n fun resetCell(cell: String) {\n \n }\n\n fun getValue(formula: String): Int {\n \n }\n\n}\n\n/**\n * Your Spreadsheet object will be instantiated and called as such:\n * var obj = Spreadsheet(rows)\n * obj.setCell(cell,value)\n * obj.resetCell(cell)\n * var param_3 = obj.getValue(formula)\n */", "__typename": "CodeSnippetNode" }, { "lang": "Dart", "langSlug": "dart", "code": "class Spreadsheet {\n\n Spreadsheet(int rows) {\n \n }\n \n void setCell(String cell, int value) {\n \n }\n \n void resetCell(String cell) {\n \n }\n \n int getValue(String formula) {\n \n }\n}\n\n/**\n * Your Spreadsheet object will be instantiated and called as such:\n * Spreadsheet obj = Spreadsheet(rows);\n * obj.setCell(cell,value);\n * obj.resetCell(cell);\n * int param3 = obj.getValue(formula);\n */", "__typename": "CodeSnippetNode" }, { "lang": "Go", "langSlug": "golang", "code": "type Spreadsheet struct {\n \n}\n\n\nfunc Constructor(rows int) Spreadsheet {\n \n}\n\n\nfunc (this *Spreadsheet) SetCell(cell string, value int) {\n \n}\n\n\nfunc (this *Spreadsheet) ResetCell(cell string) {\n \n}\n\n\nfunc (this *Spreadsheet) GetValue(formula string) int {\n \n}\n\n\n/**\n * Your Spreadsheet object will be instantiated and called as such:\n * obj := Constructor(rows);\n * obj.SetCell(cell,value);\n * obj.ResetCell(cell);\n * param_3 := obj.GetValue(formula);\n */", "__typename": "CodeSnippetNode" }, { "lang": "Ruby", "langSlug": "ruby", "code": "class Spreadsheet\n\n=begin\n :type rows: Integer\n=end\n def initialize(rows)\n \n end\n\n\n=begin\n :type cell: String\n :type value: Integer\n :rtype: Void\n=end\n def set_cell(cell, value)\n \n end\n\n\n=begin\n :type cell: String\n :rtype: Void\n=end\n def reset_cell(cell)\n \n end\n\n\n=begin\n :type formula: String\n :rtype: Integer\n=end\n def get_value(formula)\n \n end\n\n\nend\n\n# Your Spreadsheet object will be instantiated and called as such:\n# obj = Spreadsheet.new(rows)\n# obj.set_cell(cell, value)\n# obj.reset_cell(cell)\n# param_3 = obj.get_value(formula)", "__typename": "CodeSnippetNode" }, { "lang": "Scala", "langSlug": "scala", "code": "class Spreadsheet(_rows: Int) {\n\n def setCell(cell: String, value: Int): Unit = {\n \n }\n\n def resetCell(cell: String): Unit = {\n \n }\n\n def getValue(formula: String): Int = {\n \n }\n\n}\n\n/**\n * Your Spreadsheet object will be instantiated and called as such:\n * val obj = new Spreadsheet(rows)\n * obj.setCell(cell,value)\n * obj.resetCell(cell)\n * val param_3 = obj.getValue(formula)\n */", "__typename": "CodeSnippetNode" }, { "lang": "Rust", "langSlug": "rust", "code": "struct Spreadsheet {\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 Spreadsheet {\n\n fn new(rows: i32) -> Self {\n \n }\n \n fn set_cell(&self, cell: String, value: i32) {\n \n }\n \n fn reset_cell(&self, cell: String) {\n \n }\n \n fn get_value(&self, formula: String) -> i32 {\n \n }\n}\n\n/**\n * Your Spreadsheet object will be instantiated and called as such:\n * let obj = Spreadsheet::new(rows);\n * obj.set_cell(cell, value);\n * obj.reset_cell(cell);\n * let ret_3: i32 = obj.get_value(formula);\n */", "__typename": "CodeSnippetNode" }, { "lang": "Racket", "langSlug": "racket", "code": "(define spreadsheet%\n (class object%\n (super-new)\n \n ; rows : exact-integer?\n (init-field\n rows)\n \n ; set-cell : string? exact-integer? -> void?\n (define/public (set-cell cell value)\n )\n ; reset-cell : string? -> void?\n (define/public (reset-cell cell)\n )\n ; get-value : string? -> exact-integer?\n (define/public (get-value formula)\n )))\n\n;; Your spreadsheet% object will be instantiated and called as such:\n;; (define obj (new spreadsheet% [rows rows]))\n;; (send obj set-cell cell value)\n;; (send obj reset-cell cell)\n;; (define param_3 (send obj get-value formula))", "__typename": "CodeSnippetNode" }, { "lang": "Erlang", "langSlug": "erlang", "code": "-spec spreadsheet_init_(Rows :: integer()) -> any().\nspreadsheet_init_(Rows) ->\n .\n\n-spec spreadsheet_set_cell(Cell :: unicode:unicode_binary(), Value :: integer()) -> any().\nspreadsheet_set_cell(Cell, Value) ->\n .\n\n-spec spreadsheet_reset_cell(Cell :: unicode:unicode_binary()) -> any().\nspreadsheet_reset_cell(Cell) ->\n .\n\n-spec spreadsheet_get_value(Formula :: unicode:unicode_binary()) -> integer().\nspreadsheet_get_value(Formula) ->\n .\n\n\n%% Your functions will be called as such:\n%% spreadsheet_init_(Rows),\n%% spreadsheet_set_cell(Cell, Value),\n%% spreadsheet_reset_cell(Cell),\n%% Param_3 = spreadsheet_get_value(Formula),\n\n%% spreadsheet_init_ will be called before every test case, in which you can do some necessary initializations.", "__typename": "CodeSnippetNode" }, { "lang": "Elixir", "langSlug": "elixir", "code": "defmodule Spreadsheet do\n @spec init_(rows :: integer) :: any\n def init_(rows) do\n \n end\n\n @spec set_cell(cell :: String.t, value :: integer) :: any\n def set_cell(cell, value) do\n \n end\n\n @spec reset_cell(cell :: String.t) :: any\n def reset_cell(cell) do\n \n end\n\n @spec get_value(formula :: String.t) :: integer\n def get_value(formula) do\n \n end\nend\n\n# Your functions will be called as such:\n# Spreadsheet.init_(rows)\n# Spreadsheet.set_cell(cell, value)\n# Spreadsheet.reset_cell(cell)\n# param_3 = Spreadsheet.get_value(formula)\n\n# Spreadsheet.init_ will be called before every test case, in which you can do some necessary initializations.", "__typename": "CodeSnippetNode" }, { "lang": "Cangjie", "langSlug": "cangjie", "code": "class Spreadsheet {\n init(rows: Int64) {\n\n }\n \n func setCell(cell: String, value: Int64): Unit {\n\n }\n \n func resetCell(cell: String): Unit {\n\n }\n \n func getValue(formula: String): Int64 {\n\n }\n}\n\n/**\n * Your Spreadsheet object will be instantiated and called as such:\n * let obj: Spreadsheet = Spreadsheet(rows)\n * obj.setCell(cell,value)\n * obj.resetCell(cell)\n * let param_3 = obj.getValue(formula)\n */", "__typename": "CodeSnippetNode" } ], "stats": "{\"totalAccepted\": \"1.9K\", \"totalSubmission\": \"3.1K\", \"totalAcceptedRaw\": 1855, \"totalSubmissionRaw\": 3129, \"acRate\": \"59.3%\"}", "hints": [ "Use a hashmap to represent the cells, where the key is the cell reference (e.g., \"A1\") and the value is the integer stored in the cell.", "For setCell, simply assign the given value to the specified cell in the hashmap.", "For resetCell, set the value of the specified cell to 0 in the hashmap.", "For getValue, find the values of the operands from the hashmap and return their sum." ], "solution": null, "status": null, "sampleTestCase": "[\"Spreadsheet\",\"getValue\",\"setCell\",\"getValue\",\"setCell\",\"getValue\",\"resetCell\",\"getValue\"]\n[[3],[\"=5+7\"],[\"A1\",10],[\"=A1+6\"],[\"B2\",15],[\"=A1+B2\"],[\"A1\"],[\"=A1+B2\"]]", "metaData": "{\n \"classname\": \"Spreadsheet\",\n \"constructor\": {\n \"params\": [\n {\n \"type\": \"integer\",\n \"name\": \"rows\"\n }\n ]\n },\n \"methods\": [\n {\n \"params\": [\n {\n \"type\": \"string\",\n \"name\": \"cell\"\n },\n {\n \"type\": \"integer\",\n \"name\": \"value\"\n }\n ],\n \"name\": \"setCell\",\n \"return\": {\n \"type\": \"void\"\n }\n },\n {\n \"params\": [\n {\n \"type\": \"string\",\n \"name\": \"cell\"\n }\n ],\n \"name\": \"resetCell\",\n \"return\": {\n \"type\": \"void\"\n }\n },\n {\n \"params\": [\n {\n \"type\": \"string\",\n \"name\": \"formula\"\n }\n ],\n \"name\": \"getValue\",\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++\",\"

\\u7248\\u672c\\uff1aclang 19<\\/code> \\u91c7\\u7528\\u6700\\u65b0 C++ 23 \\u6807\\u51c6\\uff0c\\u5e76\\u4f7f\\u7528 GCC 14 \\u63d0\\u4f9b\\u7684 libstdc++<\\/code>\\u3002<\\/p>\\r\\n\\r\\n

\\u7f16\\u8bd1\\u65f6\\uff0c\\u5c06\\u4f1a\\u91c7\\u7528 -O2<\\/code> \\u7ea7\\u4f18\\u5316\\uff0c\\u5e76\\u63d0\\u4f9b -gline-tables-only<\\/code> \\u53c2\\u6570\\u3002AddressSanitizer<\\/a> \\u4e5f\\u88ab\\u5f00\\u542f\\u6765\\u68c0\\u6d4b out-of-bounds<\\/code> \\u548c use-after-free<\\/code> \\u9519\\u8bef\\u3002<\\/p>\\r\\n\\r\\n

\\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\",\"

\\u7248\\u672c\\uff1aOpenJDK 21<\\/code>\\u3002\\u4f7f\\u7528\\u7f16\\u8bd1\\u53c2\\u6570 --enable-preview --release 21<\\/code><\\/p>\\r\\n\\r\\n

\\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

\\u5305\\u542b Pair \\u7c7b: https:\\/\\/docs.oracle.com\\/javase\\/8\\/javafx\\/api\\/javafx\\/util\\/Pair.html <\\/p>\"],\"python\":[\"Python\",\"

\\u7248\\u672c\\uff1a Python 2.7.18<\\/code><\\/p>\\r\\n\\r\\n

\\u4e3a\\u4e86\\u65b9\\u4fbf\\u8d77\\u89c1\\uff0c\\u5927\\u90e8\\u5206\\u5e38\\u7528\\u5e93\\u5df2\\u7ecf\\u88ab\\u81ea\\u52a8 \\u5bfc\\u5165\\uff0c\\u5982\\uff1aarray<\\/a>, bisect<\\/a>, 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

\\u6ce8\\u610f Python 2.7 \\u5df2\\u4e0d\\u518d\\u7ef4\\u62a4<\\/a>\\u3002 \\u5982\\u60f3\\u4f7f\\u7528\\u6700\\u65b0\\u7248\\u7684Python\\uff0c\\u8bf7\\u9009\\u62e9Python 3\\u3002<\\/p>\"],\"c\":[\"C\",\"

\\u7248\\u672c\\uff1aGCC 14<\\/code>\\uff0c\\u91c7\\u7528 GNU11 \\u6807\\u51c6\\u3002<\\/p>\\r\\n\\r\\n

\\u7f16\\u8bd1\\u65f6\\uff0c\\u5c06\\u4f1a\\u91c7\\u7528 -O2<\\/code> \\u7ea7\\u4f18\\u5316\\uff0c\\u5e76\\u63d0\\u4f9b -g1<\\/code> \\u53c2\\u6570\\u3002 AddressSanitizer<\\/a> \\u4e5f\\u88ab\\u5f00\\u542f\\u6765\\u68c0\\u6d4b out-of-bounds<\\/code> \\u548c use-after-free<\\/code> \\u9519\\u8bef\\u3002<\\/p>\\r\\n\\r\\n

\\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

\\u5982\\u60f3\\u4f7f\\u7528\\u54c8\\u5e0c\\u8868\\u8fd0\\u7b97, \\u60a8\\u53ef\\u4ee5\\u4f7f\\u7528 uthash<\\/a>\\u3002 \\\"uthash.h\\\"\\u5df2\\u7ecf\\u9ed8\\u8ba4\\u88ab\\u5bfc\\u5165\\u3002\\u8bf7\\u770b\\u5982\\u4e0b\\u793a\\u4f8b:<\\/p>\\r\\n\\r\\n

1. \\u5f80\\u54c8\\u5e0c\\u8868\\u4e2d\\u6dfb\\u52a0\\u4e00\\u4e2a\\u5bf9\\u8c61\\uff1a<\\/b>\\r\\n

\\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

2. \\u5728\\u54c8\\u5e0c\\u8868\\u4e2d\\u67e5\\u627e\\u4e00\\u4e2a\\u5bf9\\u8c61\\uff1a<\\/b>\\r\\n

\\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

3. \\u4ece\\u54c8\\u5e0c\\u8868\\u4e2d\\u5220\\u9664\\u4e00\\u4e2a\\u5bf9\\u8c61\\uff1a<\\/b>\\r\\n

\\r\\nvoid delete_user(struct hash_entry *user) {\\r\\n    HASH_DEL(users, user);  \\r\\n}\\r\\n<\\/pre>\\r\\n<\\/p>\"],\"csharp\":[\"C#\",\"

C# 13<\\/a> \\u8fd0\\u884c\\u5728 .NET 9 \\u4e0a<\\/p>\"],\"javascript\":[\"JavaScript\",\"

\\u7248\\u672c\\uff1aNode.js 22.14.0<\\/code><\\/p>\\r\\n\\r\\n

\\u60a8\\u7684\\u4ee3\\u7801\\u5728\\u6267\\u884c\\u65f6\\u5c06\\u5e26\\u4e0a --harmony<\\/code> \\u6807\\u8bb0\\u6765\\u5f00\\u542f \\u65b0\\u7248ES6\\u7279\\u6027<\\/a>\\u3002<\\/p>\\r\\n\\r\\n

lodash.js<\\/a> \\u5e93\\u5df2\\u7ecf\\u9ed8\\u8ba4\\u88ab\\u5305\\u542b\\u3002<\\/p>\\r\\n\\r\\n

\\u5982\\u9700\\u4f7f\\u7528\\u961f\\u5217\\/\\u4f18\\u5148\\u961f\\u5217\\uff0c\\u60a8\\u53ef\\u4f7f\\u7528 datastructures-js\\/priority-queue@6.3.2<\\/a>\\uff0c datastructures-js\\/queue@4.2.3<\\/a> \\u4ee5\\u53ca datastructures-js\\/deque@1.0.4<\\/a>\\u3002<\\/p>\"],\"ruby\":[\"Ruby\",\"

\\u4f7f\\u7528 Ruby 3.2<\\/code> \\u6267\\u884c<\\/p>\\r\\n\\r\\n

\\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\",\"

\\u7248\\u672c\\uff1aSwift 6.0<\\/code><\\/p>\\r\\n\\r\\n

\\u60a8\\u53ef\\u4ee5\\u4f7f\\u7528 swift-algorithms 1.2.0<\\/a>\\uff0cswift-collections 1.1.4<\\/a> \\u548c swift-numerics 1.0.2<\\/a><\\/p>\\r\\n\\r\\n

\\u6211\\u4eec\\u901a\\u5e38\\u4fdd\\u8bc1\\u66f4\\u65b0\\u5230 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\",\"

\\u7248\\u672c\\uff1aGo 1.23<\\/code><\\/p>\\r\\n\\r\\n

\\u652f\\u6301 https:\\/\\/pkg.go.dev\\/github.com\\/emirpasic\\/gods@v1.18.1<\\/a> \\u548c https:\\/\\/pkg.go.dev\\/github.com\\/emirpasic\\/gods\\/v2@v2.0.0-alpha<\\/a> \\u7b2c\\u4e09\\u65b9\\u5e93\\u3002<\\/p>\"],\"python3\":[\"Python3\",\"

\\u7248\\u672c\\uff1aPython 3.11<\\/code><\\/p>\\r\\n\\r\\n

\\u4e3a\\u4e86\\u65b9\\u4fbf\\u8d77\\u89c1\\uff0c\\u5927\\u90e8\\u5206\\u5e38\\u7528\\u5e93\\u5df2\\u7ecf\\u88ab\\u81ea\\u52a8 \\u5bfc\\u5165\\uff0c\\u5982array<\\/a>, bisect<\\/a>, 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

\\u5982\\u9700\\u4f7f\\u7528 Map\\/TreeMap \\u6570\\u636e\\u7ed3\\u6784\\uff0c\\u60a8\\u53ef\\u4f7f\\u7528 sortedcontainers<\\/a> \\u5e93\\u3002<\\/p>\"],\"scala\":[\"Scala\",\"

\\u7248\\u672c\\uff1aScala 3.3.1<\\/code><\\/p>\"],\"kotlin\":[\"Kotlin\",\"

\\u7248\\u672c\\uff1aKotlin 2.1.10<\\/code><\\/p>\"],\"rust\":[\"Rust\",\"

\\u7248\\u672c\\uff1arust 1.85.0<\\/code><\\/p>\\r\\n\\r\\n

\\u652f\\u6301 crates.io \\u7684 rand<\\/a>\\u3001regex<\\/a> \\u548c itertools<\\/a><\\/p>\"],\"php\":[\"PHP\",\"

PHP 8.2<\\/code>.<\\/p>\\r\\n\\r\\n

With bcmath module.<\\/p>\"],\"typescript\":[\"TypeScript\",\"

TypeScript 5.7.3<\\/p>\\r\\n\\r\\n

Compile Options: --alwaysStrict --strictBindCallApply --strictFunctionTypes --target ES2024<\\/p>\\r\\n\\r\\n

lodash.js<\\/a> \\u5e93\\u5df2\\u7ecf\\u9ed8\\u8ba4\\u88ab\\u5305\\u542b\\u3002<\\/p>\\r\\n\\r\\n

\\u5982\\u9700\\u4f7f\\u7528\\u961f\\u5217\\/\\u4f18\\u5148\\u961f\\u5217\\uff0c\\u60a8\\u53ef\\u4f7f\\u7528 datastructures-js\\/priority-queue@6.3.2<\\/a>\\uff0c datastructures-js\\/queue@4.2.3<\\/a> \\u4ee5\\u53ca datastructures-js\\/deque@1.0.4<\\/a>\\u3002<\\/p>\"],\"racket\":[\"Racket\",\"

Racket CS<\\/a> v8.15<\\/p>\\r\\n\\r\\n

\\u4f7f\\u7528 #lang racket<\\/p>\\r\\n\\r\\n

\\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\",\"

Dart 3.2\\u3002\\u60a8\\u53ef\\u4ee5\\u4f7f\\u7528 collection<\\/a> \\u5305<\\/p>\\r\\n\\r\\n

\\u60a8\\u7684\\u4ee3\\u7801\\u5c06\\u4f1a\\u88ab\\u4e0d\\u7f16\\u8bd1\\u76f4\\u63a5\\u8fd0\\u884c<\\/p>\"],\"cangjie\":[\"Cangjie\",\"

\\u7248\\u672c\\uff1a0.53.11 (cjnative)<\\/p>\\r\\n\\r\\n

\\u7f16\\u8bd1\\u53c2\\u6570\\uff1a-O2 --disable-reflection<\\/code><\\/p>\\r\\n\\r\\n

\\u5feb\\u901f\\u5165\\u95e8\\u8bf7\\u67e5\\u9605\\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": "[\"Spreadsheet\",\"getValue\",\"setCell\",\"getValue\",\"setCell\",\"getValue\",\"resetCell\",\"getValue\"]\n[[3],[\"=5+7\"],[\"A1\",10],[\"=A1+6\"],[\"B2\",15],[\"=A1+B2\"],[\"A1\"],[\"=A1+B2\"]]", "__typename": "QuestionNode" } } }