From 5a4fa6db128c7f7c7c3df590334cab75747b06b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E5=91=98=E5=B0=8F=E5=A2=A8?= <2291200076@qq.com> Date: Sun, 27 Mar 2022 20:23:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=BD=E5=86=85=E7=89=88=E9=A2=98=E7=9B=AE?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E4=B8=8B=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 国内版.py | 5 +- 算法题(国内版)/originData/05ZEDJ.json | 181 ++++++++++++++++ 算法题(国内版)/originData/0jQkd0.json | 187 ++++++++++++++++ 算法题(国内版)/originData/2AoeFn.json | 192 +++++++++++++++++ 算法题(国内版)/originData/7WHec2.json | 204 ++++++++++++++++++ 算法题(国内版)/originData/K8GULz.json | 187 ++++++++++++++++ 算法题(国内版)/originData/TVdhkn.json | 192 +++++++++++++++++ 算法题(国内版)/originData/Y1VbOX.json | 181 ++++++++++++++++ 算法题(国内版)/originData/bLyHh0.json | 198 +++++++++++++++++ 算法题(国内版)/originData/fHi6rV.json | 169 +++++++++++++++ 算法题(国内版)/originData/fsa7oZ.json | 187 ++++++++++++++++ 算法题(国内版)/originData/kplEvH.json | 187 ++++++++++++++++ 算法题(国内版)/originData/oPs9Bm.json | 175 +++++++++++++++ 算法题(国内版)/originData/sZ59z6.json | 193 +++++++++++++++++ 算法题(国内版)/originData/uOAnQW.json | 163 ++++++++++++++ 算法题(国内版)/originData/uUsW3B.json | 186 ++++++++++++++++ 算法题(国内版)/originData/vFjcfV.json | 199 +++++++++++++++++ 算法题(国内版)/originData/vvXgSW.json | 198 +++++++++++++++++ 算法题(国内版)/originData/xx4gT2.json | 204 ++++++++++++++++++ .../problem (Chinese)/入场安检 [oPs9Bm].md | 51 +++++ .../problem (Chinese)/十字路口的交通 [Y1VbOX].md | 46 ++++ .../problem (Chinese)/合并排序链表 [vvXgSW].html | 51 +++++ .../含有 k 个元素的组合 [uUsW3B].html | 36 ++++ .../problem (Chinese)/开幕式焰火 [sZ59z6].md | 23 ++ .../problem (Chinese)/心算挑战 [uOAnQW].md | 22 ++ .../problem (Chinese)/志愿者调配 [05ZEDJ].md | 44 ++++ .../problem (Chinese)/所有子集 [TVdhkn].html | 33 +++ .../数组中的第 k 大的数字 [xx4gT2].html | 31 +++ .../problem (Chinese)/无人机方阵 [0jQkd0].md | 45 ++++ .../problem (Chinese)/无限棋局 [fsa7oZ].md | 35 +++ .../problem (Chinese)/玩具套圈 [vFjcfV].md | 37 ++++ .../problem (Chinese)/环形闯关游戏 [K8GULz].md | 48 +++++ .../problem (Chinese)/省份数量 [bLyHh0].html | 42 ++++ .../problem (Chinese)/自行车炫技赛场 [kplEvH].md | 33 +++ .../problem (Chinese)/路径的数目 [2AoeFn].html | 53 +++++ .../problem (Chinese)/链表排序 [7WHec2].html | 48 +++++ .../problem (Chinese)/黑白翻转棋 [fHi6rV].md | 43 ++++ .../合并排序链表(English) [vvXgSW].html | 1 + .../含有 k 个元素的组合(English) [uUsW3B].html | 1 + .../problem (English)/所有子集(English) [TVdhkn].html | 1 + .../数组中的第 k 大的数字(English) [xx4gT2].html | 1 + .../problem (English)/省份数量(English) [bLyHh0].html | 1 + .../路径的数目(English) [2AoeFn].html | 1 + .../problem (English)/链表排序(English) [7WHec2].html | 1 + 44 files changed, 4112 insertions(+), 4 deletions(-) create mode 100644 算法题(国内版)/originData/05ZEDJ.json create mode 100644 算法题(国内版)/originData/0jQkd0.json create mode 100644 算法题(国内版)/originData/2AoeFn.json create mode 100644 算法题(国内版)/originData/7WHec2.json create mode 100644 算法题(国内版)/originData/K8GULz.json create mode 100644 算法题(国内版)/originData/TVdhkn.json create mode 100644 算法题(国内版)/originData/Y1VbOX.json create mode 100644 算法题(国内版)/originData/bLyHh0.json create mode 100644 算法题(国内版)/originData/fHi6rV.json create mode 100644 算法题(国内版)/originData/fsa7oZ.json create mode 100644 算法题(国内版)/originData/kplEvH.json create mode 100644 算法题(国内版)/originData/oPs9Bm.json create mode 100644 算法题(国内版)/originData/sZ59z6.json create mode 100644 算法题(国内版)/originData/uOAnQW.json create mode 100644 算法题(国内版)/originData/uUsW3B.json create mode 100644 算法题(国内版)/originData/vFjcfV.json create mode 100644 算法题(国内版)/originData/vvXgSW.json create mode 100644 算法题(国内版)/originData/xx4gT2.json create mode 100644 算法题(国内版)/problem (Chinese)/入场安检 [oPs9Bm].md create mode 100644 算法题(国内版)/problem (Chinese)/十字路口的交通 [Y1VbOX].md create mode 100644 算法题(国内版)/problem (Chinese)/合并排序链表 [vvXgSW].html create mode 100644 算法题(国内版)/problem (Chinese)/含有 k 个元素的组合 [uUsW3B].html create mode 100644 算法题(国内版)/problem (Chinese)/开幕式焰火 [sZ59z6].md create mode 100644 算法题(国内版)/problem (Chinese)/心算挑战 [uOAnQW].md create mode 100644 算法题(国内版)/problem (Chinese)/志愿者调配 [05ZEDJ].md create mode 100644 算法题(国内版)/problem (Chinese)/所有子集 [TVdhkn].html create mode 100644 算法题(国内版)/problem (Chinese)/数组中的第 k 大的数字 [xx4gT2].html create mode 100644 算法题(国内版)/problem (Chinese)/无人机方阵 [0jQkd0].md create mode 100644 算法题(国内版)/problem (Chinese)/无限棋局 [fsa7oZ].md create mode 100644 算法题(国内版)/problem (Chinese)/玩具套圈 [vFjcfV].md create mode 100644 算法题(国内版)/problem (Chinese)/环形闯关游戏 [K8GULz].md create mode 100644 算法题(国内版)/problem (Chinese)/省份数量 [bLyHh0].html create mode 100644 算法题(国内版)/problem (Chinese)/自行车炫技赛场 [kplEvH].md create mode 100644 算法题(国内版)/problem (Chinese)/路径的数目 [2AoeFn].html create mode 100644 算法题(国内版)/problem (Chinese)/链表排序 [7WHec2].html create mode 100644 算法题(国内版)/problem (Chinese)/黑白翻转棋 [fHi6rV].md create mode 100644 算法题(国内版)/problem (English)/合并排序链表(English) [vvXgSW].html create mode 100644 算法题(国内版)/problem (English)/含有 k 个元素的组合(English) [uUsW3B].html create mode 100644 算法题(国内版)/problem (English)/所有子集(English) [TVdhkn].html create mode 100644 算法题(国内版)/problem (English)/数组中的第 k 大的数字(English) [xx4gT2].html create mode 100644 算法题(国内版)/problem (English)/省份数量(English) [bLyHh0].html create mode 100644 算法题(国内版)/problem (English)/路径的数目(English) [2AoeFn].html create mode 100644 算法题(国内版)/problem (English)/链表排序(English) [7WHec2].html diff --git a/国内版.py b/国内版.py index 11529212..dde0a9aa 100644 --- a/国内版.py +++ b/国内版.py @@ -18,7 +18,7 @@ def get_proble_set(url): return None def parse_proble_set(problemSet): - print(len(problemSet)) # 2573 + # print(len(problemSet)) # 2573 for i in range(len(problemSet)): title = problemSet[i]["stat"]["question__title_slug"] if os.path.exists("originData/[no content]{}.json".format(title)) or os.path.exists("originData/{}.json".format(title)): @@ -30,10 +30,7 @@ def parse_proble_set(problemSet): time.sleep(1) t =threading.Thread(target=construct_url,args=(title,)) t.start() - print(i, "is done.") - if i > 15: - break # 临时 continue def construct_url(problemTitle): diff --git a/算法题(国内版)/originData/05ZEDJ.json b/算法题(国内版)/originData/05ZEDJ.json new file mode 100644 index 00000000..80f4849f --- /dev/null +++ b/算法题(国内版)/originData/05ZEDJ.json @@ -0,0 +1,181 @@ +{ + "data": { + "question": { + "questionId": "1000373", + "questionFrontendId": "LCP 46", + "categoryTitle": "Algorithms", + "boundTopicId": 1016616, + "title": "志愿者调配", + "titleSlug": "05ZEDJ", + "content": "", + "translatedTitle": "志愿者调配", + "translatedContent": "「力扣挑战赛」有 `n` 个比赛场馆(场馆编号从 `0` 开始),场馆之间的通道分布情况记录于二维数组 `edges` 中,`edges[i]= [x, y]` 表示第 `i` 条通道连接场馆 `x` 和场馆 `y`(即两个场馆相邻)。初始每个场馆中都有一定人数的志愿者(不同场馆人数可能不同),后续 `m` 天每天均会根据赛事热度进行志愿者人数调配。调配方案分为如下三种:\n1. 将编号为 `idx` 的场馆内的志愿者人数减半;\n2. 将编号为 `idx` 的场馆相邻的场馆的志愿者人数都加上编号为 `idx` 的场馆的志愿者人数;\n3. 将编号为 `idx` 的场馆相邻的场馆的志愿者人数都减去编号为 `idx` 的场馆的志愿者人数。\n\n所有的调配信息记录于数组 `plans` 中,`plans[i] = [num,idx]` 表示第 `i` 天对编号 `idx` 的场馆执行了第 `num` 种调配方案。\n在比赛结束后对调配方案进行复盘时,不慎将第 `0` 个场馆的**最终**志愿者人数丢失,只保留了**初始**所有场馆的志愿者总人数 `totalNum` ,以及记录了第 `1 ~ n-1` 个场馆的**最终**志愿者人数的一维数组 `finalCnt`。请你根据现有的信息求出初始每个场馆的志愿者人数,并按场馆编号顺序返回志愿者人数列表。\n\n**注意:**\n- 测试数据保证当某场馆进行第一种调配时,该场馆的志愿者人数一定为偶数;\n- 测试数据保证当某场馆进行第三种调配时,该场馆的相邻场馆志愿者人数不为负数;\n- 测试数据保证比赛开始时每个场馆的志愿者人数都不超过 `10^9`;\n- 测试数据保证给定的场馆间的道路分布情况中不会出现自环、重边的情况。\n\n\n**示例 1:**\n>![image.png](https://pic.leetcode-cn.com/1630061228-gnZsOz-image.png)\n> 输入:\n>`finalCnt = [1,16], totalNum = 21, edges = [[0,1],[1,2]], plans = [[2,1],[1,0],[3,0]]`\n>\n> 输出:`[5,7,9]`\n>\n> 解释:\n> ![image.png](https://pic.leetcode-cn.com/1630061300-WuVkeF-image.png){:height=200}\n\n\n**示例 2 :**\n> 输入:\n>`finalCnt = [4,13,4,3,8], totalNum = 54, edges = [[0,3],[1,3],[4,3],[2,3],[2,5]], plans = [[1,1],[3,3],[2,5],[1,0]]`\n>\n> 输出:`[10,16,9,4,7,8]`\n\n\n\n**提示:**\n- `2 <= n <= 5*10^4`\n- `1 <= edges.length <= min((n * (n - 1)) / 2, 5*10^4)`\n- `0 <= edges[i][0], edges[i][1] < n`\n- `1 <= plans.length <= 10`\n- `1 <= plans[i][0] <=3`\n- `0 <= plans[i][1] < n`\n- `finalCnt.length = n-1`\n- `0 <= finalCnt[i] < 10^9`\n- `0 <= totalNum < 5*10^13`\n", + "isPaidOnly": false, + "difficulty": "Medium", + "likes": 2, + "dislikes": 0, + "isLiked": null, + "similarQuestions": "[]", + "contributors": [ + { + "username": "LeetCode", + "profileUrl": "/u/leetcode", + "avatarUrl": "https://assets.leetcode-cn.com/aliyun-lc-upload/uploaded_files/2021/03/73c9f099-abbe-4d94-853f-f8abffd459cd/leetcode.png", + "__typename": "ContributorNode" + } + ], + "langToValidPlayground": "{\"cpp\": false, \"java\": false, \"python\": false, \"python3\": false, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"ruby\": false, \"bash\": false, \"swift\": false, \"golang\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"kotlin\": false, \"rust\": false, \"php\": false, \"typescript\": false, \"racket\": false, \"erlang\": false, \"elixir\": false}", + "topicTags": [ + { + "name": "Graph", + "slug": "graph", + "translatedName": "图", + "__typename": "TopicTagNode" + }, + { + "name": "Array", + "slug": "array", + "translatedName": "数组", + "__typename": "TopicTagNode" + }, + { + "name": "Math", + "slug": "math", + "translatedName": "数学", + "__typename": "TopicTagNode" + } + ], + "companyTagStats": null, + "codeSnippets": [ + { + "lang": "C++", + "langSlug": "cpp", + "code": "class Solution {\npublic:\n vector volunteerDeployment(vector& finalCnt, long long totalNum, vector>& edges, vector>& plans) {\n\n }\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Java", + "langSlug": "java", + "code": "class Solution {\n public int[] volunteerDeployment(int[] finalCnt, long totalNum, int[][] edges, int[][] plans) {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Python", + "langSlug": "python", + "code": "class Solution(object):\n def volunteerDeployment(self, finalCnt, totalNum, edges, plans):\n \"\"\"\n :type finalCnt: List[int]\n :type totalNum: int\n :type edges: List[List[int]]\n :type plans: List[List[int]]\n :rtype: List[int]\n \"\"\"", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Python3", + "langSlug": "python3", + "code": "class Solution:\n def volunteerDeployment(self, finalCnt: List[int], totalNum: int, edges: List[List[int]], plans: List[List[int]]) -> List[int]:", + "__typename": "CodeSnippetNode" + }, + { + "lang": "C", + "langSlug": "c", + "code": "\n\n/**\n * Note: The returned array must be malloced, assume caller calls free().\n */\nint* volunteerDeployment(int* finalCnt, int finalCntSize, long long totalNum, int** edges, int edgesSize, int* edgesColSize, int** plans, int plansSize, int* plansColSize, int* returnSize){\n\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "C#", + "langSlug": "csharp", + "code": "public class Solution {\n public int[] VolunteerDeployment(int[] finalCnt, long totalNum, int[][] edges, int[][] plans) {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "JavaScript", + "langSlug": "javascript", + "code": "/**\n * @param {number[]} finalCnt\n * @param {number} totalNum\n * @param {number[][]} edges\n * @param {number[][]} plans\n * @return {number[]}\n */\nvar volunteerDeployment = function(finalCnt, totalNum, edges, plans) {\n\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Ruby", + "langSlug": "ruby", + "code": "# @param {Integer[]} final_cnt\n# @param {Integer} total_num\n# @param {Integer[][]} edges\n# @param {Integer[][]} plans\n# @return {Integer[]}\ndef volunteer_deployment(final_cnt, total_num, edges, plans)\n\nend", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Swift", + "langSlug": "swift", + "code": "class Solution {\n func volunteerDeployment(_ finalCnt: [Int], _ totalNum: Int, _ edges: [[Int]], _ plans: [[Int]]) -> [Int] {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Go", + "langSlug": "golang", + "code": "func volunteerDeployment(finalCnt []int, totalNum int64, edges [][]int, plans [][]int) []int {\n\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Scala", + "langSlug": "scala", + "code": "object Solution {\n def volunteerDeployment(finalCnt: Array[Int], totalNum: Long, edges: Array[Array[Int]], plans: Array[Array[Int]]): Array[Int] = {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Kotlin", + "langSlug": "kotlin", + "code": "class Solution {\n fun volunteerDeployment(finalCnt: IntArray, totalNum: Long, edges: Array, plans: Array): IntArray {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Rust", + "langSlug": "rust", + "code": "impl Solution {\n pub fn volunteer_deployment(final_cnt: Vec, total_num: i64, edges: Vec>, plans: Vec>) -> Vec {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "PHP", + "langSlug": "php", + "code": "class Solution {\n\n /**\n * @param Integer[] $finalCnt\n * @param Integer $totalNum\n * @param Integer[][] $edges\n * @param Integer[][] $plans\n * @return Integer[]\n */\n function volunteerDeployment($finalCnt, $totalNum, $edges, $plans) {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "TypeScript", + "langSlug": "typescript", + "code": "function volunteerDeployment(finalCnt: number[], totalNum: number, edges: number[][], plans: number[][]): number[] {\n\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Racket", + "langSlug": "racket", + "code": "(define/contract (volunteer-deployment finalCnt totalNum edges plans)\n (-> (listof exact-integer?) exact-integer? (listof (listof exact-integer?)) (listof (listof exact-integer?)) (listof exact-integer?))\n\n )", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Erlang", + "langSlug": "erlang", + "code": "-spec volunteer_deployment(FinalCnt :: [integer()], TotalNum :: integer(), Edges :: [[integer()]], Plans :: [[integer()]]) -> [integer()].\nvolunteer_deployment(FinalCnt, TotalNum, Edges, Plans) ->\n .", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Elixir", + "langSlug": "elixir", + "code": "defmodule Solution do\n @spec volunteer_deployment(final_cnt :: [integer], total_num :: integer, edges :: [[integer]], plans :: [[integer]]) :: [integer]\n def volunteer_deployment(final_cnt, total_num, edges, plans) do\n\n end\nend", + "__typename": "CodeSnippetNode" + } + ], + "stats": "{\"totalAccepted\": \"1.1K\", \"totalSubmission\": \"2.7K\", \"totalAcceptedRaw\": 1121, \"totalSubmissionRaw\": 2724, \"acRate\": \"41.2%\"}", + "hints": [], + "solution": null, + "status": null, + "sampleTestCase": "[1,16]\n21\n[[0,1],[1,2]]\n[[2,1],[1,0],[3,0]]", + "metaData": "{\"name\": \"volunteerDeployment\", \"params\": [{\"name\": \"finalCnt\", \"type\": \"integer[]\"}, {\"name\": \"totalNum\", \"type\": \"long\"}, {\"name\": \"edges\", \"type\": \"integer[][]\"}, {\"name\": \"plans\", \"type\": \"integer[][]\"}], \"return\": {\"type\": \"integer[]\"}}", + "judgerAvailable": true, + "judgeType": "large", + "mysqlSchemas": [], + "enableRunCode": true, + "envInfo": "{\"cpp\":[\"C++\",\"

\\u7248\\u672c\\uff1aclang 11<\\/code> \\u91c7\\u7528\\u6700\\u65b0C++ 17\\u6807\\u51c6\\u3002<\\/p>\\r\\n\\r\\n

\\u7f16\\u8bd1\\u65f6\\uff0c\\u5c06\\u4f1a\\u91c7\\u7528-O2<\\/code>\\u7ea7\\u4f18\\u5316\\u3002AddressSanitizer<\\/a> \\u4e5f\\u88ab\\u5f00\\u542f\\u6765\\u68c0\\u6d4bout-of-bounds<\\/code>\\u548cuse-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 17<\\/code>\\u3002\\u53ef\\u4ee5\\u4f7f\\u7528Java 8\\u7684\\u7279\\u6027\\u4f8b\\u5982\\uff0clambda expressions \\u548c stream API\\u3002<\\/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.12<\\/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 \\u5c06\\u57282020\\u5e74\\u540e\\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 8.2<\\/code>\\uff0c\\u91c7\\u7528GNU99\\u6807\\u51c6\\u3002<\\/p>\\r\\n\\r\\n

\\u7f16\\u8bd1\\u65f6\\uff0c\\u5c06\\u4f1a\\u91c7\\u7528-O1<\\/code>\\u7ea7\\u4f18\\u5316\\u3002 AddressSanitizer<\\/a>\\u4e5f\\u88ab\\u5f00\\u542f\\u6765\\u68c0\\u6d4bout-of-bounds<\\/code>\\u548cuse-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# 10<\\/a> \\u8fd0\\u884c\\u5728 .NET 6 \\u4e0a<\\/p>\\r\\n\\r\\n

\\u60a8\\u7684\\u4ee3\\u7801\\u5728\\u7f16\\u8bd1\\u65f6\\u9ed8\\u8ba4\\u5f00\\u542f\\u4e86debug\\u6807\\u8bb0(\\/debug:pdbonly<\\/code>)\\u3002<\\/p>\"],\"javascript\":[\"JavaScript\",\"

\\u7248\\u672c\\uff1aNode.js 16.13.2<\\/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<\\/a> \\u548c datastructures-js\\/queue<\\/a>\\u3002<\\/p>\"],\"ruby\":[\"Ruby\",\"

\\u4f7f\\u7528Ruby 3.1<\\/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 5.5.2<\\/code><\\/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.17<\\/code><\\/p>\\r\\n\\r\\n

\\u652f\\u6301 https:\\/\\/godoc.org\\/github.com\\/emirpasic\\/gods<\\/a> \\u7b2c\\u4e09\\u65b9\\u5e93\\u3002<\\/p>\"],\"python3\":[\"Python3\",\"

\\u7248\\u672c\\uff1aPython 3.10<\\/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 2.13<\\/code><\\/p>\"],\"kotlin\":[\"Kotlin\",\"

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

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

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

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

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

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

Compile Options: --alwaysStrict --strictBindCallApply --strictFunctionTypes --target ES2020<\\/p>\"],\"racket\":[\"Racket\",\"

Racket CS<\\/a> v8.3<\\/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 24.2\"],\"elixir\":[\"Elixir\",\"Elixir 1.13.0 with Erlang\\/OTP 24.2\"]}", + "book": null, + "isSubscribed": false, + "isDailyQuestion": false, + "dailyRecordStatus": null, + "editorType": "MARKDOWN", + "ugcQuestionId": null, + "style": "LEETCODE", + "exampleTestcases": "[1,16]\n21\n[[0,1],[1,2]]\n[[2,1],[1,0],[3,0]]", + "__typename": "QuestionNode" + } + } +} \ No newline at end of file diff --git a/算法题(国内版)/originData/0jQkd0.json b/算法题(国内版)/originData/0jQkd0.json new file mode 100644 index 00000000..f9b7b4a1 --- /dev/null +++ b/算法题(国内版)/originData/0jQkd0.json @@ -0,0 +1,187 @@ +{ + "data": { + "question": { + "questionId": "1000369", + "questionFrontendId": "LCP 39", + "categoryTitle": "Algorithms", + "boundTopicId": 987418, + "title": "无人机方阵", + "titleSlug": "0jQkd0", + "content": "", + "translatedTitle": "无人机方阵", + "translatedContent": "在 「力扣挑战赛」 开幕式的压轴节目 「无人机方阵」中,每一架无人机展示一种灯光颜色。 无人机方阵通过两种操作进行颜色图案变换:\n- 调整无人机的位置布局\n- 切换无人机展示的灯光颜色\n\n\n给定两个大小均为 `N*M` 的二维数组 `source` 和 `target` 表示无人机方阵表演的两种颜色图案,由于无人机切换灯光颜色的耗能很大,请返回从 `source` 到 `target` 最少需要多少架无人机切换灯光颜色。\n\n\n**注意:** 调整无人机的位置布局时无人机的位置可以随意变动。\n\n\n**示例 1:**\n> 输入:`source = [[1,3],[5,4]], target = [[3,1],[6,5]]`\n>\n> 输出:`1`\n>\n> 解释:\n> 最佳方案为\n将 `[0,1]` 处的无人机移动至 `[0,0]` 处;\n将 `[0,0]` 处的无人机移动至 `[0,1]` 处;\n将 `[1,0]` 处的无人机移动至 `[1,1]` 处;\n将 `[1,1]` 处的无人机移动至 `[1,0]` 处,其灯光颜色切换为颜色编号为 `6` 的灯光;\n因此从`source` 到 `target` 所需要的最少灯光切换次数为 1。\n>![8819ccdd664e91c78cde3bba3c701986.gif](https://pic.leetcode-cn.com/1628823765-uCDaux-8819ccdd664e91c78cde3bba3c701986.gif){:height=300px}\n\n\n\n\n\n**示例 2:**\n> 输入:`source = [[1,2,3],[3,4,5]], target = [[1,3,5],[2,3,4]]`\n>\n> 输出:`0`\n> 解释:\n> 仅需调整无人机的位置布局,便可完成图案切换。因此不需要无人机切换颜色\n\n\n**提示:**\n`n == source.length == target.length`\n`m == source[i].length == target[i].length`\n`1 <= n, m <=100`\n`1 <= source[i][j], target[i][j] <=10^4`\n\n\n\n", + "isPaidOnly": false, + "difficulty": "Easy", + "likes": 5, + "dislikes": 0, + "isLiked": null, + "similarQuestions": "[]", + "contributors": [ + { + "username": "LeetCode", + "profileUrl": "/u/leetcode", + "avatarUrl": "https://assets.leetcode-cn.com/aliyun-lc-upload/uploaded_files/2021/03/73c9f099-abbe-4d94-853f-f8abffd459cd/leetcode.png", + "__typename": "ContributorNode" + } + ], + "langToValidPlayground": "{\"cpp\": false, \"java\": true, \"python\": true, \"python3\": false, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"ruby\": false, \"bash\": false, \"swift\": false, \"golang\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"kotlin\": false, \"rust\": false, \"php\": false, \"typescript\": false, \"racket\": false, \"erlang\": false, \"elixir\": false}", + "topicTags": [ + { + "name": "Array", + "slug": "array", + "translatedName": "数组", + "__typename": "TopicTagNode" + }, + { + "name": "Hash Table", + "slug": "hash-table", + "translatedName": "哈希表", + "__typename": "TopicTagNode" + }, + { + "name": "Counting", + "slug": "counting", + "translatedName": "计数", + "__typename": "TopicTagNode" + }, + { + "name": "Matrix", + "slug": "matrix", + "translatedName": "矩阵", + "__typename": "TopicTagNode" + } + ], + "companyTagStats": null, + "codeSnippets": [ + { + "lang": "C++", + "langSlug": "cpp", + "code": "class Solution {\npublic:\n int minimumSwitchingTimes(vector>& source, vector>& target) {\n\n }\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Java", + "langSlug": "java", + "code": "class Solution {\n public int minimumSwitchingTimes(int[][] source, int[][] target) {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Python", + "langSlug": "python", + "code": "class Solution(object):\n def minimumSwitchingTimes(self, source, target):\n \"\"\"\n :type source: List[List[int]]\n :type target: List[List[int]]\n :rtype: int\n \"\"\"", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Python3", + "langSlug": "python3", + "code": "class Solution:\n def minimumSwitchingTimes(self, source: List[List[int]], target: List[List[int]]) -> int:", + "__typename": "CodeSnippetNode" + }, + { + "lang": "C", + "langSlug": "c", + "code": "\n\nint minimumSwitchingTimes(int** source, int sourceSize, int* sourceColSize, int** target, int targetSize, int* targetColSize){\n\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "C#", + "langSlug": "csharp", + "code": "public class Solution {\n public int MinimumSwitchingTimes(int[][] source, int[][] target) {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "JavaScript", + "langSlug": "javascript", + "code": "/**\n * @param {number[][]} source\n * @param {number[][]} target\n * @return {number}\n */\nvar minimumSwitchingTimes = function(source, target) {\n\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Ruby", + "langSlug": "ruby", + "code": "# @param {Integer[][]} source\n# @param {Integer[][]} target\n# @return {Integer}\ndef minimum_switching_times(source, target)\n\nend", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Swift", + "langSlug": "swift", + "code": "class Solution {\n func minimumSwitchingTimes(_ source: [[Int]], _ target: [[Int]]) -> Int {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Go", + "langSlug": "golang", + "code": "func minimumSwitchingTimes(source [][]int, target [][]int) int {\n\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Scala", + "langSlug": "scala", + "code": "object Solution {\n def minimumSwitchingTimes(source: Array[Array[Int]], target: Array[Array[Int]]): Int = {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Kotlin", + "langSlug": "kotlin", + "code": "class Solution {\n fun minimumSwitchingTimes(source: Array, target: Array): Int {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Rust", + "langSlug": "rust", + "code": "impl Solution {\n pub fn minimum_switching_times(source: Vec>, target: Vec>) -> i32 {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "PHP", + "langSlug": "php", + "code": "class Solution {\n\n /**\n * @param Integer[][] $source\n * @param Integer[][] $target\n * @return Integer\n */\n function minimumSwitchingTimes($source, $target) {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "TypeScript", + "langSlug": "typescript", + "code": "function minimumSwitchingTimes(source: number[][], target: number[][]): number {\n\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Racket", + "langSlug": "racket", + "code": "(define/contract (minimum-switching-times source target)\n (-> (listof (listof exact-integer?)) (listof (listof exact-integer?)) exact-integer?)\n\n )", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Erlang", + "langSlug": "erlang", + "code": "-spec minimum_switching_times(Source :: [[integer()]], Target :: [[integer()]]) -> integer().\nminimum_switching_times(Source, Target) ->\n .", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Elixir", + "langSlug": "elixir", + "code": "defmodule Solution do\n @spec minimum_switching_times(source :: [[integer]], target :: [[integer]]) :: integer\n def minimum_switching_times(source, target) do\n\n end\nend", + "__typename": "CodeSnippetNode" + } + ], + "stats": "{\"totalAccepted\": \"5.1K\", \"totalSubmission\": \"9.7K\", \"totalAcceptedRaw\": 5098, \"totalSubmissionRaw\": 9699, \"acRate\": \"52.6%\"}", + "hints": [], + "solution": null, + "status": null, + "sampleTestCase": "[[1,3],[5,4]]\n[[3,1],[5,4]]", + "metaData": "{\"name\": \"minimumSwitchingTimes\", \"params\": [{\"name\": \"source\", \"type\": \"integer[][]\"}, {\"name\": \"target\", \"type\": \"integer[][]\"}], \"return\": {\"type\": \"integer\"}}", + "judgerAvailable": true, + "judgeType": "large", + "mysqlSchemas": [], + "enableRunCode": true, + "envInfo": "{\"cpp\":[\"C++\",\"

\\u7248\\u672c\\uff1aclang 11<\\/code> \\u91c7\\u7528\\u6700\\u65b0C++ 17\\u6807\\u51c6\\u3002<\\/p>\\r\\n\\r\\n

\\u7f16\\u8bd1\\u65f6\\uff0c\\u5c06\\u4f1a\\u91c7\\u7528-O2<\\/code>\\u7ea7\\u4f18\\u5316\\u3002AddressSanitizer<\\/a> \\u4e5f\\u88ab\\u5f00\\u542f\\u6765\\u68c0\\u6d4bout-of-bounds<\\/code>\\u548cuse-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 17<\\/code>\\u3002\\u53ef\\u4ee5\\u4f7f\\u7528Java 8\\u7684\\u7279\\u6027\\u4f8b\\u5982\\uff0clambda expressions \\u548c stream API\\u3002<\\/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.12<\\/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 \\u5c06\\u57282020\\u5e74\\u540e\\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 8.2<\\/code>\\uff0c\\u91c7\\u7528GNU99\\u6807\\u51c6\\u3002<\\/p>\\r\\n\\r\\n

\\u7f16\\u8bd1\\u65f6\\uff0c\\u5c06\\u4f1a\\u91c7\\u7528-O1<\\/code>\\u7ea7\\u4f18\\u5316\\u3002 AddressSanitizer<\\/a>\\u4e5f\\u88ab\\u5f00\\u542f\\u6765\\u68c0\\u6d4bout-of-bounds<\\/code>\\u548cuse-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# 10<\\/a> \\u8fd0\\u884c\\u5728 .NET 6 \\u4e0a<\\/p>\\r\\n\\r\\n

\\u60a8\\u7684\\u4ee3\\u7801\\u5728\\u7f16\\u8bd1\\u65f6\\u9ed8\\u8ba4\\u5f00\\u542f\\u4e86debug\\u6807\\u8bb0(\\/debug:pdbonly<\\/code>)\\u3002<\\/p>\"],\"javascript\":[\"JavaScript\",\"

\\u7248\\u672c\\uff1aNode.js 16.13.2<\\/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<\\/a> \\u548c datastructures-js\\/queue<\\/a>\\u3002<\\/p>\"],\"ruby\":[\"Ruby\",\"

\\u4f7f\\u7528Ruby 3.1<\\/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 5.5.2<\\/code><\\/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.17<\\/code><\\/p>\\r\\n\\r\\n

\\u652f\\u6301 https:\\/\\/godoc.org\\/github.com\\/emirpasic\\/gods<\\/a> \\u7b2c\\u4e09\\u65b9\\u5e93\\u3002<\\/p>\"],\"python3\":[\"Python3\",\"

\\u7248\\u672c\\uff1aPython 3.10<\\/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 2.13<\\/code><\\/p>\"],\"kotlin\":[\"Kotlin\",\"

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

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

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

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

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

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

Compile Options: --alwaysStrict --strictBindCallApply --strictFunctionTypes --target ES2020<\\/p>\"],\"racket\":[\"Racket\",\"

Racket CS<\\/a> v8.3<\\/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 24.2\"],\"elixir\":[\"Elixir\",\"Elixir 1.13.0 with Erlang\\/OTP 24.2\"]}", + "book": null, + "isSubscribed": false, + "isDailyQuestion": false, + "dailyRecordStatus": null, + "editorType": "MARKDOWN", + "ugcQuestionId": null, + "style": "LEETCODE", + "exampleTestcases": "[[1,3],[5,4]]\n[[3,1],[5,4]]\n[[1,2,3],[3,4,5]]\n[[1,3,5],[2,3,4]]", + "__typename": "QuestionNode" + } + } +} \ No newline at end of file diff --git a/算法题(国内版)/originData/2AoeFn.json b/算法题(国内版)/originData/2AoeFn.json new file mode 100644 index 00000000..f92698f7 --- /dev/null +++ b/算法题(国内版)/originData/2AoeFn.json @@ -0,0 +1,192 @@ +{ + "data": { + "question": { + "questionId": "1000345", + "questionFrontendId": "剑指 Offer II 098", + "categoryTitle": "LCOF2", + "boundTopicId": 910430, + "title": "路径的数目", + "titleSlug": "2AoeFn", + "content": "

English description is not available for the problem. Please switch to Chinese.

\n", + "translatedTitle": "路径的数目", + "translatedContent": "

一个机器人位于一个 m x n 网格的左上角 (起始点在下图中标记为 “Start” )。

\n\n

机器人每次只能向下或者向右移动一步。机器人试图达到网格的右下角(在下图中标记为 “Finish” )。

\n\n

问总共有多少条不同的路径?

\n\n

 

\n\n

示例 1:

\n\n

\n\n
\n输入:m = 3, n = 7\n输出:28
\n\n

示例 2:

\n\n
\n输入:m = 3, n = 2\n输出:3\n解释:\n从左上角开始,总共有 3 条路径可以到达右下角。\n1. 向右 -> 向下 -> 向下\n2. 向下 -> 向下 -> 向右\n3. 向下 -> 向右 -> 向下\n
\n\n

示例 3:

\n\n
\n输入:m = 7, n = 3\n输出:28\n
\n\n

示例 4:

\n\n
\n输入:m = 3, n = 3\n输出:6
\n\n

 

\n\n

提示:

\n\n
    \n\t
  • 1 <= m, n <= 100
  • \n\t
  • 题目数据保证答案小于等于 2 * 109
  • \n
\n\n

 

\n\n

注意:本题与主站 62 题相同: https://leetcode-cn.com/problems/unique-paths/

\n", + "isPaidOnly": false, + "difficulty": "Medium", + "likes": 13, + "dislikes": 0, + "isLiked": null, + "similarQuestions": "[]", + "contributors": [ + { + "username": "LeetCode", + "profileUrl": "/u/leetcode", + "avatarUrl": "https://assets.leetcode-cn.com/aliyun-lc-upload/uploaded_files/2021/03/73c9f099-abbe-4d94-853f-f8abffd459cd/leetcode.png", + "__typename": "ContributorNode" + } + ], + "langToValidPlayground": "{\"cpp\": true, \"java\": true, \"python\": true, \"python3\": true, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"ruby\": false, \"bash\": false, \"swift\": false, \"golang\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"kotlin\": false, \"rust\": false, \"php\": false, \"typescript\": false, \"racket\": false, \"erlang\": false, \"elixir\": false}", + "topicTags": [ + { + "name": "Math", + "slug": "math", + "translatedName": "数学", + "__typename": "TopicTagNode" + }, + { + "name": "Dynamic Programming", + "slug": "dynamic-programming", + "translatedName": "动态规划", + "__typename": "TopicTagNode" + }, + { + "name": "Combinatorics", + "slug": "combinatorics", + "translatedName": "组合数学", + "__typename": "TopicTagNode" + } + ], + "companyTagStats": null, + "codeSnippets": [ + { + "lang": "C++", + "langSlug": "cpp", + "code": "class Solution {\npublic:\n int uniquePaths(int m, int n) {\n\n }\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Java", + "langSlug": "java", + "code": "class Solution {\n public int uniquePaths(int m, int n) {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Python", + "langSlug": "python", + "code": "class Solution(object):\n def uniquePaths(self, m, n):\n \"\"\"\n :type m: int\n :type n: int\n :rtype: int\n \"\"\"", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Python3", + "langSlug": "python3", + "code": "class Solution:\n def uniquePaths(self, m: int, n: int) -> int:", + "__typename": "CodeSnippetNode" + }, + { + "lang": "C", + "langSlug": "c", + "code": "\n\nint uniquePaths(int m, int n){\n\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "C#", + "langSlug": "csharp", + "code": "public class Solution {\n public int UniquePaths(int m, int n) {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "JavaScript", + "langSlug": "javascript", + "code": "/**\n * @param {number} m\n * @param {number} n\n * @return {number}\n */\nvar uniquePaths = function(m, n) {\n\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Ruby", + "langSlug": "ruby", + "code": "# @param {Integer} m\n# @param {Integer} n\n# @return {Integer}\ndef unique_paths(m, n)\n\nend", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Swift", + "langSlug": "swift", + "code": "class Solution {\n func uniquePaths(_ m: Int, _ n: Int) -> Int {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Go", + "langSlug": "golang", + "code": "func uniquePaths(m int, n int) int {\n\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Scala", + "langSlug": "scala", + "code": "object Solution {\n def uniquePaths(m: Int, n: Int): Int = {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Kotlin", + "langSlug": "kotlin", + "code": "class Solution {\n fun uniquePaths(m: Int, n: Int): Int {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Rust", + "langSlug": "rust", + "code": "impl Solution {\n pub fn unique_paths(m: i32, n: i32) -> i32 {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "PHP", + "langSlug": "php", + "code": "class Solution {\n\n /**\n * @param Integer $m\n * @param Integer $n\n * @return Integer\n */\n function uniquePaths($m, $n) {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "TypeScript", + "langSlug": "typescript", + "code": "function uniquePaths(m: number, n: number): number {\n\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Racket", + "langSlug": "racket", + "code": "(define/contract (unique-paths m n)\n (-> exact-integer? exact-integer? exact-integer?)\n\n )", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Erlang", + "langSlug": "erlang", + "code": "-spec unique_paths(M :: integer(), N :: integer()) -> integer().\nunique_paths(M, N) ->\n .", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Elixir", + "langSlug": "elixir", + "code": "defmodule Solution do\n @spec unique_paths(m :: integer, n :: integer) :: integer\n def unique_paths(m, n) do\n\n end\nend", + "__typename": "CodeSnippetNode" + } + ], + "stats": "{\"totalAccepted\": \"6.7K\", \"totalSubmission\": \"8.7K\", \"totalAcceptedRaw\": 6652, \"totalSubmissionRaw\": 8720, \"acRate\": \"76.3%\"}", + "hints": [], + "solution": null, + "status": null, + "sampleTestCase": "3\n7", + "metaData": "{\"name\": \"uniquePaths\", \"params\": [{\"name\": \"m\", \"type\": \"integer\"}, {\"name\": \"n\", \"type\": \"integer\"}], \"return\": {\"type\": \"integer\"}}", + "judgerAvailable": true, + "judgeType": "large", + "mysqlSchemas": [], + "enableRunCode": true, + "envInfo": "{\"cpp\":[\"C++\",\"

\\u7248\\u672c\\uff1aclang 11<\\/code> \\u91c7\\u7528\\u6700\\u65b0C++ 17\\u6807\\u51c6\\u3002<\\/p>\\r\\n\\r\\n

\\u7f16\\u8bd1\\u65f6\\uff0c\\u5c06\\u4f1a\\u91c7\\u7528-O2<\\/code>\\u7ea7\\u4f18\\u5316\\u3002AddressSanitizer<\\/a> \\u4e5f\\u88ab\\u5f00\\u542f\\u6765\\u68c0\\u6d4bout-of-bounds<\\/code>\\u548cuse-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 17<\\/code>\\u3002\\u53ef\\u4ee5\\u4f7f\\u7528Java 8\\u7684\\u7279\\u6027\\u4f8b\\u5982\\uff0clambda expressions \\u548c stream API\\u3002<\\/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.12<\\/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 \\u5c06\\u57282020\\u5e74\\u540e\\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 8.2<\\/code>\\uff0c\\u91c7\\u7528GNU99\\u6807\\u51c6\\u3002<\\/p>\\r\\n\\r\\n

\\u7f16\\u8bd1\\u65f6\\uff0c\\u5c06\\u4f1a\\u91c7\\u7528-O1<\\/code>\\u7ea7\\u4f18\\u5316\\u3002 AddressSanitizer<\\/a>\\u4e5f\\u88ab\\u5f00\\u542f\\u6765\\u68c0\\u6d4bout-of-bounds<\\/code>\\u548cuse-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# 10<\\/a> \\u8fd0\\u884c\\u5728 .NET 6 \\u4e0a<\\/p>\\r\\n\\r\\n

\\u60a8\\u7684\\u4ee3\\u7801\\u5728\\u7f16\\u8bd1\\u65f6\\u9ed8\\u8ba4\\u5f00\\u542f\\u4e86debug\\u6807\\u8bb0(\\/debug:pdbonly<\\/code>)\\u3002<\\/p>\"],\"javascript\":[\"JavaScript\",\"

\\u7248\\u672c\\uff1aNode.js 16.13.2<\\/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<\\/a> \\u548c datastructures-js\\/queue<\\/a>\\u3002<\\/p>\"],\"ruby\":[\"Ruby\",\"

\\u4f7f\\u7528Ruby 3.1<\\/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 5.5.2<\\/code><\\/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.17<\\/code><\\/p>\\r\\n\\r\\n

\\u652f\\u6301 https:\\/\\/godoc.org\\/github.com\\/emirpasic\\/gods<\\/a> \\u7b2c\\u4e09\\u65b9\\u5e93\\u3002<\\/p>\"],\"python3\":[\"Python3\",\"

\\u7248\\u672c\\uff1aPython 3.10<\\/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 2.13<\\/code><\\/p>\"],\"kotlin\":[\"Kotlin\",\"

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

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

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

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

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

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

Compile Options: --alwaysStrict --strictBindCallApply --strictFunctionTypes --target ES2020<\\/p>\"],\"racket\":[\"Racket\",\"

Racket CS<\\/a> v8.3<\\/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 24.2\"],\"elixir\":[\"Elixir\",\"Elixir 1.13.0 with Erlang\\/OTP 24.2\"]}", + "book": { + "id": "8", + "bookName": "《剑指 Offer(专项突击版)》", + "pressName": "电子工业出版社", + "source": "《剑指 Offer(专项突击版)》独家授权", + "shortDescription": "通行全球的程序员经典面试秘籍", + "fullDescription": "本书精选国内外名企高频面试题并深度拓展,系统地总结了程序员面试中必备的数据结构与算法知识,并以面试者及面试官的双向视角剖析考点与解题思路,适合所有正在准备面试的程序员阅读。", + "bookImgUrl": "https://pic.leetcode-cn.com/1626752512-sWgHof-image.png", + "pressImgUrl": "https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2020/02/11/logo-01.png", + "productUrl": "", + "__typename": "CategoryInfoNode" + }, + "isSubscribed": false, + "isDailyQuestion": false, + "dailyRecordStatus": null, + "editorType": "CKEDITOR", + "ugcQuestionId": null, + "style": "LEETCODE", + "exampleTestcases": "3\n7\n3\n2\n7\n3\n3\n3", + "__typename": "QuestionNode" + } + } +} \ No newline at end of file diff --git a/算法题(国内版)/originData/7WHec2.json b/算法题(国内版)/originData/7WHec2.json new file mode 100644 index 00000000..2e9960c3 --- /dev/null +++ b/算法题(国内版)/originData/7WHec2.json @@ -0,0 +1,204 @@ +{ + "data": { + "question": { + "questionId": "1000341", + "questionFrontendId": "剑指 Offer II 077", + "categoryTitle": "LCOF2", + "boundTopicId": 910335, + "title": "链表排序", + "titleSlug": "7WHec2", + "content": "

English description is not available for the problem. Please switch to Chinese.

\n", + "translatedTitle": "链表排序", + "translatedContent": "

给定链表的头结点 head ,请将其按 升序 排列并返回 排序后的链表

\n\n
    \n
\n\n

 

\n\n

示例 1:

\n\n

\"\"

\n\n
\n输入:head = [4,2,1,3]\n输出:[1,2,3,4]\n
\n\n

示例 2:

\n\n

\"\"

\n\n
\n输入:head = [-1,5,3,4,0]\n输出:[-1,0,3,4,5]\n
\n\n

示例 3:

\n\n
\n输入:head = []\n输出:[]\n
\n\n

 

\n\n

提示:

\n\n
    \n\t
  • 链表中节点的数目在范围 [0, 5 * 104] 内
  • \n\t
  • -105 <= Node.val <= 105
  • \n
\n\n

 

\n\n

进阶:你可以在 O(n log n) 时间复杂度和常数级空间复杂度下,对链表进行排序吗?

\n\n

 

\n\n

注意:本题与主站 148 题相同:https://leetcode-cn.com/problems/sort-list/

\n", + "isPaidOnly": false, + "difficulty": "Medium", + "likes": 43, + "dislikes": 0, + "isLiked": null, + "similarQuestions": "[]", + "contributors": [ + { + "username": "LeetCode", + "profileUrl": "/u/leetcode", + "avatarUrl": "https://assets.leetcode-cn.com/aliyun-lc-upload/uploaded_files/2021/03/73c9f099-abbe-4d94-853f-f8abffd459cd/leetcode.png", + "__typename": "ContributorNode" + } + ], + "langToValidPlayground": "{\"cpp\": true, \"java\": true, \"python\": true, \"python3\": true, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"ruby\": false, \"bash\": false, \"swift\": false, \"golang\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"kotlin\": false, \"rust\": false, \"php\": false, \"typescript\": false, \"racket\": false, \"erlang\": false, \"elixir\": false}", + "topicTags": [ + { + "name": "Linked List", + "slug": "linked-list", + "translatedName": "链表", + "__typename": "TopicTagNode" + }, + { + "name": "Two Pointers", + "slug": "two-pointers", + "translatedName": "双指针", + "__typename": "TopicTagNode" + }, + { + "name": "Divide and Conquer", + "slug": "divide-and-conquer", + "translatedName": "分治", + "__typename": "TopicTagNode" + }, + { + "name": "Sorting", + "slug": "sorting", + "translatedName": "排序", + "__typename": "TopicTagNode" + }, + { + "name": "Merge Sort", + "slug": "merge-sort", + "translatedName": "归并排序", + "__typename": "TopicTagNode" + } + ], + "companyTagStats": null, + "codeSnippets": [ + { + "lang": "C++", + "langSlug": "cpp", + "code": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\nclass Solution {\npublic:\n ListNode* sortList(ListNode* head) {\n\n }\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Java", + "langSlug": "java", + "code": "/**\n * Definition for singly-linked list.\n * public class ListNode {\n * int val;\n * ListNode next;\n * ListNode() {}\n * ListNode(int val) { this.val = val; }\n * ListNode(int val, ListNode next) { this.val = val; this.next = next; }\n * }\n */\nclass Solution {\n public ListNode sortList(ListNode head) {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Python", + "langSlug": "python", + "code": "# Definition for singly-linked list.\n# class ListNode(object):\n# def __init__(self, val=0, next=None):\n# self.val = val\n# self.next = next\nclass Solution(object):\n def sortList(self, head):\n \"\"\"\n :type head: ListNode\n :rtype: ListNode\n \"\"\"", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Python3", + "langSlug": "python3", + "code": "# Definition for singly-linked list.\n# class ListNode:\n# def __init__(self, val=0, next=None):\n# self.val = val\n# self.next = next\nclass Solution:\n def sortList(self, head: ListNode) -> ListNode:", + "__typename": "CodeSnippetNode" + }, + { + "lang": "C", + "langSlug": "c", + "code": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * struct ListNode *next;\n * };\n */\n\n\nstruct ListNode* sortList(struct ListNode* head){\n\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "C#", + "langSlug": "csharp", + "code": "/**\n * Definition for singly-linked list.\n * public class ListNode {\n * public int val;\n * public ListNode next;\n * public ListNode(int val=0, ListNode next=null) {\n * this.val = val;\n * this.next = next;\n * }\n * }\n */\npublic class Solution {\n public ListNode SortList(ListNode head) {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "JavaScript", + "langSlug": "javascript", + "code": "/**\n * Definition for singly-linked list.\n * function ListNode(val, next) {\n * this.val = (val===undefined ? 0 : val)\n * this.next = (next===undefined ? null : next)\n * }\n */\n/**\n * @param {ListNode} head\n * @return {ListNode}\n */\nvar sortList = function(head) {\n\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Ruby", + "langSlug": "ruby", + "code": "# Definition for singly-linked list.\n# class ListNode\n# attr_accessor :val, :next\n# def initialize(val = 0, _next = nil)\n# @val = val\n# @next = _next\n# end\n# end\n# @param {ListNode} head\n# @return {ListNode}\ndef sort_list(head)\n\nend", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Swift", + "langSlug": "swift", + "code": "/**\n * Definition for singly-linked list.\n * public class ListNode {\n * public var val: Int\n * public var next: ListNode?\n * public init() { self.val = 0; self.next = nil; }\n * public init(_ val: Int) { self.val = val; self.next = nil; }\n * public init(_ val: Int, _ next: ListNode?) { self.val = val; self.next = next; }\n * }\n */\nclass Solution {\n func sortList(_ head: ListNode?) -> ListNode? {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Go", + "langSlug": "golang", + "code": "/**\n * Definition for singly-linked list.\n * type ListNode struct {\n * Val int\n * Next *ListNode\n * }\n */\nfunc sortList(head *ListNode) *ListNode {\n\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Scala", + "langSlug": "scala", + "code": "/**\n * Definition for singly-linked list.\n * class ListNode(_x: Int = 0, _next: ListNode = null) {\n * var next: ListNode = _next\n * var x: Int = _x\n * }\n */\nobject Solution {\n def sortList(head: ListNode): ListNode = {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Kotlin", + "langSlug": "kotlin", + "code": "/**\n * Example:\n * var li = ListNode(5)\n * var v = li.`val`\n * Definition for singly-linked list.\n * class ListNode(var `val`: Int) {\n * var next: ListNode? = null\n * }\n */\nclass Solution {\n fun sortList(head: ListNode?): ListNode? {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Rust", + "langSlug": "rust", + "code": "// Definition for singly-linked list.\n// #[derive(PartialEq, Eq, Clone, Debug)]\n// pub struct ListNode {\n// pub val: i32,\n// pub next: Option>\n// }\n//\n// impl ListNode {\n// #[inline]\n// fn new(val: i32) -> Self {\n// ListNode {\n// next: None,\n// val\n// }\n// }\n// }\nimpl Solution {\n pub fn sort_list(head: Option>) -> Option> {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "PHP", + "langSlug": "php", + "code": "/**\n * Definition for a singly-linked list.\n * class ListNode {\n * public $val = 0;\n * public $next = null;\n * function __construct($val = 0, $next = null) {\n * $this->val = $val;\n * $this->next = $next;\n * }\n * }\n */\nclass Solution {\n\n /**\n * @param ListNode $head\n * @return ListNode\n */\n function sortList($head) {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "TypeScript", + "langSlug": "typescript", + "code": "/**\n * Definition for singly-linked list.\n * class ListNode {\n * val: number\n * next: ListNode | null\n * constructor(val?: number, next?: ListNode | null) {\n * this.val = (val===undefined ? 0 : val)\n * this.next = (next===undefined ? null : next)\n * }\n * }\n */\n\nfunction sortList(head: ListNode | null): ListNode | null {\n\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Racket", + "langSlug": "racket", + "code": "; Definition for singly-linked list:\n#|\n\n; val : integer?\n; next : (or/c list-node? #f)\n(struct list-node\n (val next) #:mutable #:transparent)\n\n; constructor\n(define (make-list-node [val 0])\n (list-node val #f))\n\n|#\n\n(define/contract (sort-list head)\n (-> (or/c list-node? #f) (or/c list-node? #f))\n\n )", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Erlang", + "langSlug": "erlang", + "code": "%% Definition for singly-linked list.\n%%\n%% -record(list_node, {val = 0 :: integer(),\n%% next = null :: 'null' | #list_node{}}).\n\n-spec sort_list(Head :: #list_node{} | null) -> #list_node{} | null.\nsort_list(Head) ->\n .", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Elixir", + "langSlug": "elixir", + "code": "# Definition for singly-linked list.\n#\n# defmodule ListNode do\n# @type t :: %__MODULE__{\n# val: integer,\n# next: ListNode.t() | nil\n# }\n# defstruct val: 0, next: nil\n# end\n\ndefmodule Solution do\n @spec sort_list(head :: ListNode.t | nil) :: ListNode.t | nil\n def sort_list(head) do\n\n end\nend", + "__typename": "CodeSnippetNode" + } + ], + "stats": "{\"totalAccepted\": \"12.8K\", \"totalSubmission\": \"21K\", \"totalAcceptedRaw\": 12753, \"totalSubmissionRaw\": 20968, \"acRate\": \"60.8%\"}", + "hints": [], + "solution": null, + "status": null, + "sampleTestCase": "[4,2,1,3]", + "metaData": "{\"name\": \"sortList\", \"params\": [{\"name\": \"head\", \"type\": \"ListNode\"}], \"return\": {\"type\": \"ListNode\"}}", + "judgerAvailable": true, + "judgeType": "large", + "mysqlSchemas": [], + "enableRunCode": true, + "envInfo": "{\"cpp\":[\"C++\",\"

\\u7248\\u672c\\uff1aclang 11<\\/code> \\u91c7\\u7528\\u6700\\u65b0C++ 17\\u6807\\u51c6\\u3002<\\/p>\\r\\n\\r\\n

\\u7f16\\u8bd1\\u65f6\\uff0c\\u5c06\\u4f1a\\u91c7\\u7528-O2<\\/code>\\u7ea7\\u4f18\\u5316\\u3002AddressSanitizer<\\/a> \\u4e5f\\u88ab\\u5f00\\u542f\\u6765\\u68c0\\u6d4bout-of-bounds<\\/code>\\u548cuse-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 17<\\/code>\\u3002\\u53ef\\u4ee5\\u4f7f\\u7528Java 8\\u7684\\u7279\\u6027\\u4f8b\\u5982\\uff0clambda expressions \\u548c stream API\\u3002<\\/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.12<\\/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 \\u5c06\\u57282020\\u5e74\\u540e\\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 8.2<\\/code>\\uff0c\\u91c7\\u7528GNU99\\u6807\\u51c6\\u3002<\\/p>\\r\\n\\r\\n

\\u7f16\\u8bd1\\u65f6\\uff0c\\u5c06\\u4f1a\\u91c7\\u7528-O1<\\/code>\\u7ea7\\u4f18\\u5316\\u3002 AddressSanitizer<\\/a>\\u4e5f\\u88ab\\u5f00\\u542f\\u6765\\u68c0\\u6d4bout-of-bounds<\\/code>\\u548cuse-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# 10<\\/a> \\u8fd0\\u884c\\u5728 .NET 6 \\u4e0a<\\/p>\\r\\n\\r\\n

\\u60a8\\u7684\\u4ee3\\u7801\\u5728\\u7f16\\u8bd1\\u65f6\\u9ed8\\u8ba4\\u5f00\\u542f\\u4e86debug\\u6807\\u8bb0(\\/debug:pdbonly<\\/code>)\\u3002<\\/p>\"],\"javascript\":[\"JavaScript\",\"

\\u7248\\u672c\\uff1aNode.js 16.13.2<\\/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<\\/a> \\u548c datastructures-js\\/queue<\\/a>\\u3002<\\/p>\"],\"ruby\":[\"Ruby\",\"

\\u4f7f\\u7528Ruby 3.1<\\/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 5.5.2<\\/code><\\/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.17<\\/code><\\/p>\\r\\n\\r\\n

\\u652f\\u6301 https:\\/\\/godoc.org\\/github.com\\/emirpasic\\/gods<\\/a> \\u7b2c\\u4e09\\u65b9\\u5e93\\u3002<\\/p>\"],\"python3\":[\"Python3\",\"

\\u7248\\u672c\\uff1aPython 3.10<\\/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 2.13<\\/code><\\/p>\"],\"kotlin\":[\"Kotlin\",\"

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

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

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

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

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

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

Compile Options: --alwaysStrict --strictBindCallApply --strictFunctionTypes --target ES2020<\\/p>\"],\"racket\":[\"Racket\",\"

Racket CS<\\/a> v8.3<\\/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 24.2\"],\"elixir\":[\"Elixir\",\"Elixir 1.13.0 with Erlang\\/OTP 24.2\"]}", + "book": { + "id": "8", + "bookName": "《剑指 Offer(专项突击版)》", + "pressName": "电子工业出版社", + "source": "《剑指 Offer(专项突击版)》独家授权", + "shortDescription": "通行全球的程序员经典面试秘籍", + "fullDescription": "本书精选国内外名企高频面试题并深度拓展,系统地总结了程序员面试中必备的数据结构与算法知识,并以面试者及面试官的双向视角剖析考点与解题思路,适合所有正在准备面试的程序员阅读。", + "bookImgUrl": "https://pic.leetcode-cn.com/1626752512-sWgHof-image.png", + "pressImgUrl": "https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2020/02/11/logo-01.png", + "productUrl": "", + "__typename": "CategoryInfoNode" + }, + "isSubscribed": false, + "isDailyQuestion": false, + "dailyRecordStatus": null, + "editorType": "CKEDITOR", + "ugcQuestionId": null, + "style": "LEETCODE", + "exampleTestcases": "[4,2,1,3]\n[-1,5,3,4,0]\n[]", + "__typename": "QuestionNode" + } + } +} \ No newline at end of file diff --git a/算法题(国内版)/originData/K8GULz.json b/算法题(国内版)/originData/K8GULz.json new file mode 100644 index 00000000..f8358e3e --- /dev/null +++ b/算法题(国内版)/originData/K8GULz.json @@ -0,0 +1,187 @@ +{ + "data": { + "question": { + "questionId": "1000359", + "questionFrontendId": "LCP 49", + "categoryTitle": "Algorithms", + "boundTopicId": 1016613, + "title": "环形闯关游戏", + "titleSlug": "K8GULz", + "content": "", + "translatedTitle": "环形闯关游戏", + "translatedContent": "「力扣挑战赛」中有一个由 `N` 个关卡组成的**环形**闯关游戏,关卡编号为 `0`~`N-1`,编号 `0` 的关卡和编号 `N-1` 的关卡相邻。每个关卡均有积分要求,`challenge[i]` 表示挑战编号 `i` 的关卡最少需要拥有的积分。\n![图片.png](https://pic.leetcode-cn.com/1630392170-ucncVS-%E5%9B%BE%E7%89%87.png){:width=\"240px\"}\n\n\n小扣想要挑战关卡,闯关的具体规则如下:\n\n- 初始小扣可以指定其中一个关卡为「开启」状态,其余关卡将处于「未开启」状态。\n- 小扣可以挑战处于「开启」状态且**满足最少积分要求**的关卡,若小扣挑战该关卡前积分为 `score`,挑战结束后,积分将增长为 `score|challenge[i]`(即位运算中的 `\"OR\"` 运算)\n- 在挑战某个关卡后,该关卡两侧相邻的关卡将会开启(若之前未开启)\n\n请帮助小扣进行计算,初始最少需要多少积分,可以挑战 **环形闯关游戏** 的所有关卡。\n\n**示例1:**\n\n> 输入:`challenge = [5,4,6,2,7]`\n>\n> 输出:`4`\n> \n> 解释: 初始选择编号 3 的关卡开启,积分为 4\n>挑战编号 3 的关卡,积分变为 $4 | 2 = 6$,开启 2、4 处的关卡\n>挑战编号 2 的关卡,积分变为 $6 | 6 = 6$,开启 1 处的关卡\n>挑战编号 1 的关卡,积分变为 $6 | 4 = 6$,开启 0 处的关卡\n>挑战编号 0 的关卡,积分变为 $6 | 5 = 7$\n>挑战编号 4 的关卡,顺利完成全部的关卡\n\n\n**示例2:**\n\n> 输入:`challenge = [12,7,11,3,9]`\n>\n> 输出:`8`\n>\n> 解释: 初始选择编号 3 的关卡开启,积分为 8\n>挑战编号 3 的关卡,积分变为 $8 | 3 = 11$,开启 2、4 处的关卡\n>挑战编号 2 的关卡,积分变为 $11 | 11 = 11$,开启 1 处的关卡\n>挑战编号 4 的关卡,积分变为 $11 | 9 = 11$,开启 0 处的关卡\n>挑战编号 1 的关卡,积分变为 $11 | 7 = 15$\n>挑战编号 0 的关卡,顺利完成全部的关卡\n\n**示例3:**\n\n> 输入:`challenge = [1,1,1]`\n>\n> 输出:`1`\n\n**提示:** \n- `1 <= challenge.length <= 5*10^4`\n- `1 <= challenge[i] <= 10^18`", + "isPaidOnly": false, + "difficulty": "Hard", + "likes": 5, + "dislikes": 0, + "isLiked": null, + "similarQuestions": "[]", + "contributors": [ + { + "username": "LeetCode", + "profileUrl": "/u/leetcode", + "avatarUrl": "https://assets.leetcode-cn.com/aliyun-lc-upload/uploaded_files/2021/03/73c9f099-abbe-4d94-853f-f8abffd459cd/leetcode.png", + "__typename": "ContributorNode" + } + ], + "langToValidPlayground": "{\"cpp\": false, \"java\": false, \"python\": false, \"python3\": false, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"ruby\": false, \"bash\": false, \"swift\": false, \"golang\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"kotlin\": false, \"rust\": false, \"php\": false, \"typescript\": false, \"racket\": false, \"erlang\": false, \"elixir\": false}", + "topicTags": [ + { + "name": "Bit Manipulation", + "slug": "bit-manipulation", + "translatedName": "位运算", + "__typename": "TopicTagNode" + }, + { + "name": "Union Find", + "slug": "union-find", + "translatedName": "并查集", + "__typename": "TopicTagNode" + }, + { + "name": "Array", + "slug": "array", + "translatedName": "数组", + "__typename": "TopicTagNode" + }, + { + "name": "Heap (Priority Queue)", + "slug": "heap-priority-queue", + "translatedName": "堆(优先队列)", + "__typename": "TopicTagNode" + } + ], + "companyTagStats": null, + "codeSnippets": [ + { + "lang": "C++", + "langSlug": "cpp", + "code": "class Solution {\npublic:\n long long ringGame(vector& challenge) {\n\n }\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Java", + "langSlug": "java", + "code": "class Solution {\n public long ringGame(long[] challenge) {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Python", + "langSlug": "python", + "code": "class Solution(object):\n def ringGame(self, challenge):\n \"\"\"\n :type challenge: List[int]\n :rtype: int\n \"\"\"", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Python3", + "langSlug": "python3", + "code": "class Solution:\n def ringGame(self, challenge: List[int]) -> int:", + "__typename": "CodeSnippetNode" + }, + { + "lang": "C", + "langSlug": "c", + "code": "\n\nlong long ringGame(long long* challenge, int challengeSize){\n\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "C#", + "langSlug": "csharp", + "code": "public class Solution {\n public long RingGame(long[] challenge) {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "JavaScript", + "langSlug": "javascript", + "code": "/**\n * @param {BigInt[]} challenge\n * @return {BigInt}\n */\nvar ringGame = function(challenge) {\n\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Ruby", + "langSlug": "ruby", + "code": "# @param {Integer[]} challenge\n# @return {Integer}\ndef ring_game(challenge)\n\nend", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Swift", + "langSlug": "swift", + "code": "class Solution {\n func ringGame(_ challenge: [Int]) -> Int {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Go", + "langSlug": "golang", + "code": "func ringGame(challenge []int64) int64 {\n\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Scala", + "langSlug": "scala", + "code": "object Solution {\n def ringGame(challenge: Array[Long]): Long = {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Kotlin", + "langSlug": "kotlin", + "code": "class Solution {\n fun ringGame(challenge: LongArray): Long {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Rust", + "langSlug": "rust", + "code": "impl Solution {\n pub fn ring_game(challenge: Vec) -> i64 {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "PHP", + "langSlug": "php", + "code": "class Solution {\n\n /**\n * @param Integer[] $challenge\n * @return Integer\n */\n function ringGame($challenge) {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "TypeScript", + "langSlug": "typescript", + "code": "function ringGame(challenge: BigInt[]): BigInt {\n\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Racket", + "langSlug": "racket", + "code": "(define/contract (ring-game challenge)\n (-> (listof exact-integer?) exact-integer?)\n\n )", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Erlang", + "langSlug": "erlang", + "code": "-spec ring_game(Challenge :: [integer()]) -> integer().\nring_game(Challenge) ->\n .", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Elixir", + "langSlug": "elixir", + "code": "defmodule Solution do\n @spec ring_game(challenge :: [integer]) :: integer\n def ring_game(challenge) do\n\n end\nend", + "__typename": "CodeSnippetNode" + } + ], + "stats": "{\"totalAccepted\": \"465\", \"totalSubmission\": \"1.7K\", \"totalAcceptedRaw\": 465, \"totalSubmissionRaw\": 1711, \"acRate\": \"27.2%\"}", + "hints": [], + "solution": null, + "status": null, + "sampleTestCase": "[5,4,6,2,7]", + "metaData": "{\"name\": \"ringGame\", \"params\": [{\"name\": \"challenge\", \"type\": \"long[]\"}], \"return\": {\"type\": \"long\"}}", + "judgerAvailable": true, + "judgeType": "large", + "mysqlSchemas": [], + "enableRunCode": true, + "envInfo": "{\"cpp\":[\"C++\",\"

\\u7248\\u672c\\uff1aclang 11<\\/code> \\u91c7\\u7528\\u6700\\u65b0C++ 17\\u6807\\u51c6\\u3002<\\/p>\\r\\n\\r\\n

\\u7f16\\u8bd1\\u65f6\\uff0c\\u5c06\\u4f1a\\u91c7\\u7528-O2<\\/code>\\u7ea7\\u4f18\\u5316\\u3002AddressSanitizer<\\/a> \\u4e5f\\u88ab\\u5f00\\u542f\\u6765\\u68c0\\u6d4bout-of-bounds<\\/code>\\u548cuse-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 17<\\/code>\\u3002\\u53ef\\u4ee5\\u4f7f\\u7528Java 8\\u7684\\u7279\\u6027\\u4f8b\\u5982\\uff0clambda expressions \\u548c stream API\\u3002<\\/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.12<\\/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 \\u5c06\\u57282020\\u5e74\\u540e\\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 8.2<\\/code>\\uff0c\\u91c7\\u7528GNU99\\u6807\\u51c6\\u3002<\\/p>\\r\\n\\r\\n

\\u7f16\\u8bd1\\u65f6\\uff0c\\u5c06\\u4f1a\\u91c7\\u7528-O1<\\/code>\\u7ea7\\u4f18\\u5316\\u3002 AddressSanitizer<\\/a>\\u4e5f\\u88ab\\u5f00\\u542f\\u6765\\u68c0\\u6d4bout-of-bounds<\\/code>\\u548cuse-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# 10<\\/a> \\u8fd0\\u884c\\u5728 .NET 6 \\u4e0a<\\/p>\\r\\n\\r\\n

\\u60a8\\u7684\\u4ee3\\u7801\\u5728\\u7f16\\u8bd1\\u65f6\\u9ed8\\u8ba4\\u5f00\\u542f\\u4e86debug\\u6807\\u8bb0(\\/debug:pdbonly<\\/code>)\\u3002<\\/p>\"],\"javascript\":[\"JavaScript\",\"

\\u7248\\u672c\\uff1aNode.js 16.13.2<\\/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<\\/a> \\u548c datastructures-js\\/queue<\\/a>\\u3002<\\/p>\"],\"ruby\":[\"Ruby\",\"

\\u4f7f\\u7528Ruby 3.1<\\/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 5.5.2<\\/code><\\/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.17<\\/code><\\/p>\\r\\n\\r\\n

\\u652f\\u6301 https:\\/\\/godoc.org\\/github.com\\/emirpasic\\/gods<\\/a> \\u7b2c\\u4e09\\u65b9\\u5e93\\u3002<\\/p>\"],\"python3\":[\"Python3\",\"

\\u7248\\u672c\\uff1aPython 3.10<\\/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 2.13<\\/code><\\/p>\"],\"kotlin\":[\"Kotlin\",\"

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

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

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

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

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

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

Compile Options: --alwaysStrict --strictBindCallApply --strictFunctionTypes --target ES2020<\\/p>\"],\"racket\":[\"Racket\",\"

Racket CS<\\/a> v8.3<\\/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 24.2\"],\"elixir\":[\"Elixir\",\"Elixir 1.13.0 with Erlang\\/OTP 24.2\"]}", + "book": null, + "isSubscribed": false, + "isDailyQuestion": false, + "dailyRecordStatus": null, + "editorType": "MARKDOWN", + "ugcQuestionId": null, + "style": "LEETCODE", + "exampleTestcases": "[5,4,6,2,7]\n[1,17,1,19,1]\n[12,7,11,3,9]", + "__typename": "QuestionNode" + } + } +} \ No newline at end of file diff --git a/算法题(国内版)/originData/TVdhkn.json b/算法题(国内版)/originData/TVdhkn.json new file mode 100644 index 00000000..26b6ac45 --- /dev/null +++ b/算法题(国内版)/originData/TVdhkn.json @@ -0,0 +1,192 @@ +{ + "data": { + "question": { + "questionId": "1000343", + "questionFrontendId": "剑指 Offer II 079", + "categoryTitle": "LCOF2", + "boundTopicId": 910337, + "title": "所有子集", + "titleSlug": "TVdhkn", + "content": "

English description is not available for the problem. Please switch to Chinese.

\n", + "translatedTitle": "所有子集", + "translatedContent": "

给定一个整数数组 nums ,数组中的元素 互不相同 。返回该数组所有可能的子集(幂集)。

\n\n

解集 不能 包含重复的子集。你可以按 任意顺序 返回解集。

\n\n

 

\n\n

示例 1:

\n\n
\n输入:nums = [1,2,3]\n输出:[[],[1],[2],[1,2],[3],[1,3],[2,3],[1,2,3]]\n
\n\n

示例 2:

\n\n
\n输入:nums = [0]\n输出:[[],[0]]\n
\n\n

 

\n\n

提示:

\n\n
    \n\t
  • 1 <= nums.length <= 10
  • \n\t
  • -10 <= nums[i] <= 10
  • \n\t
  • nums 中的所有元素 互不相同
  • \n
\n\n

 

\n\n

注意:本题与主站 78 题相同: https://leetcode-cn.com/problems/subsets/

\n", + "isPaidOnly": false, + "difficulty": "Medium", + "likes": 24, + "dislikes": 0, + "isLiked": null, + "similarQuestions": "[]", + "contributors": [ + { + "username": "LeetCode", + "profileUrl": "/u/leetcode", + "avatarUrl": "https://assets.leetcode-cn.com/aliyun-lc-upload/uploaded_files/2021/03/73c9f099-abbe-4d94-853f-f8abffd459cd/leetcode.png", + "__typename": "ContributorNode" + } + ], + "langToValidPlayground": "{\"cpp\": false, \"java\": true, \"python\": true, \"python3\": false, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"ruby\": false, \"bash\": false, \"swift\": false, \"golang\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"kotlin\": false, \"rust\": false, \"php\": false, \"typescript\": false, \"racket\": false, \"erlang\": false, \"elixir\": false}", + "topicTags": [ + { + "name": "Bit Manipulation", + "slug": "bit-manipulation", + "translatedName": "位运算", + "__typename": "TopicTagNode" + }, + { + "name": "Array", + "slug": "array", + "translatedName": "数组", + "__typename": "TopicTagNode" + }, + { + "name": "Backtracking", + "slug": "backtracking", + "translatedName": "回溯", + "__typename": "TopicTagNode" + } + ], + "companyTagStats": null, + "codeSnippets": [ + { + "lang": "C++", + "langSlug": "cpp", + "code": "class Solution {\npublic:\n vector> subsets(vector& nums) {\n\n }\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Java", + "langSlug": "java", + "code": "class Solution {\n public List> subsets(int[] nums) {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Python", + "langSlug": "python", + "code": "class Solution(object):\n def subsets(self, nums):\n \"\"\"\n :type nums: List[int]\n :rtype: List[List[int]]\n \"\"\"", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Python3", + "langSlug": "python3", + "code": "class Solution:\n def subsets(self, nums: List[int]) -> List[List[int]]:", + "__typename": "CodeSnippetNode" + }, + { + "lang": "C", + "langSlug": "c", + "code": "\n\n/**\n * Return an array of arrays of size *returnSize.\n * The sizes of the arrays are returned as *returnColumnSizes array.\n * Note: Both returned array and *columnSizes array must be malloced, assume caller calls free().\n */\nint** subsets(int* nums, int numsSize, int* returnSize, int** returnColumnSizes){\n\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "C#", + "langSlug": "csharp", + "code": "public class Solution {\n public IList> Subsets(int[] nums) {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "JavaScript", + "langSlug": "javascript", + "code": "/**\n * @param {number[]} nums\n * @return {number[][]}\n */\nvar subsets = function(nums) {\n\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Ruby", + "langSlug": "ruby", + "code": "# @param {Integer[]} nums\n# @return {Integer[][]}\ndef subsets(nums)\n\nend", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Swift", + "langSlug": "swift", + "code": "class Solution {\n func subsets(_ nums: [Int]) -> [[Int]] {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Go", + "langSlug": "golang", + "code": "func subsets(nums []int) [][]int {\n\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Scala", + "langSlug": "scala", + "code": "object Solution {\n def subsets(nums: Array[Int]): List[List[Int]] = {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Kotlin", + "langSlug": "kotlin", + "code": "class Solution {\n fun subsets(nums: IntArray): List> {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Rust", + "langSlug": "rust", + "code": "impl Solution {\n pub fn subsets(nums: Vec) -> Vec> {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "PHP", + "langSlug": "php", + "code": "class Solution {\n\n /**\n * @param Integer[] $nums\n * @return Integer[][]\n */\n function subsets($nums) {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "TypeScript", + "langSlug": "typescript", + "code": "function subsets(nums: number[]): number[][] {\n\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Racket", + "langSlug": "racket", + "code": "(define/contract (subsets nums)\n (-> (listof exact-integer?) (listof (listof exact-integer?)))\n\n )", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Erlang", + "langSlug": "erlang", + "code": "-spec subsets(Nums :: [integer()]) -> [[integer()]].\nsubsets(Nums) ->\n .", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Elixir", + "langSlug": "elixir", + "code": "defmodule Solution do\n @spec subsets(nums :: [integer]) :: [[integer]]\n def subsets(nums) do\n\n end\nend", + "__typename": "CodeSnippetNode" + } + ], + "stats": "{\"totalAccepted\": \"10.2K\", \"totalSubmission\": \"12K\", \"totalAcceptedRaw\": 10244, \"totalSubmissionRaw\": 11977, \"acRate\": \"85.5%\"}", + "hints": [], + "solution": null, + "status": null, + "sampleTestCase": "[1,2,3]", + "metaData": "{\"name\": \"subsets\", \"params\": [{\"name\": \"nums\", \"type\": \"integer[]\"}], \"return\": {\"type\": \"integer[][]\"}}", + "judgerAvailable": true, + "judgeType": "large", + "mysqlSchemas": [], + "enableRunCode": true, + "envInfo": "{\"cpp\":[\"C++\",\"

\\u7248\\u672c\\uff1aclang 11<\\/code> \\u91c7\\u7528\\u6700\\u65b0C++ 17\\u6807\\u51c6\\u3002<\\/p>\\r\\n\\r\\n

\\u7f16\\u8bd1\\u65f6\\uff0c\\u5c06\\u4f1a\\u91c7\\u7528-O2<\\/code>\\u7ea7\\u4f18\\u5316\\u3002AddressSanitizer<\\/a> \\u4e5f\\u88ab\\u5f00\\u542f\\u6765\\u68c0\\u6d4bout-of-bounds<\\/code>\\u548cuse-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 17<\\/code>\\u3002\\u53ef\\u4ee5\\u4f7f\\u7528Java 8\\u7684\\u7279\\u6027\\u4f8b\\u5982\\uff0clambda expressions \\u548c stream API\\u3002<\\/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.12<\\/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 \\u5c06\\u57282020\\u5e74\\u540e\\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 8.2<\\/code>\\uff0c\\u91c7\\u7528GNU99\\u6807\\u51c6\\u3002<\\/p>\\r\\n\\r\\n

\\u7f16\\u8bd1\\u65f6\\uff0c\\u5c06\\u4f1a\\u91c7\\u7528-O1<\\/code>\\u7ea7\\u4f18\\u5316\\u3002 AddressSanitizer<\\/a>\\u4e5f\\u88ab\\u5f00\\u542f\\u6765\\u68c0\\u6d4bout-of-bounds<\\/code>\\u548cuse-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# 10<\\/a> \\u8fd0\\u884c\\u5728 .NET 6 \\u4e0a<\\/p>\\r\\n\\r\\n

\\u60a8\\u7684\\u4ee3\\u7801\\u5728\\u7f16\\u8bd1\\u65f6\\u9ed8\\u8ba4\\u5f00\\u542f\\u4e86debug\\u6807\\u8bb0(\\/debug:pdbonly<\\/code>)\\u3002<\\/p>\"],\"javascript\":[\"JavaScript\",\"

\\u7248\\u672c\\uff1aNode.js 16.13.2<\\/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<\\/a> \\u548c datastructures-js\\/queue<\\/a>\\u3002<\\/p>\"],\"ruby\":[\"Ruby\",\"

\\u4f7f\\u7528Ruby 3.1<\\/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 5.5.2<\\/code><\\/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.17<\\/code><\\/p>\\r\\n\\r\\n

\\u652f\\u6301 https:\\/\\/godoc.org\\/github.com\\/emirpasic\\/gods<\\/a> \\u7b2c\\u4e09\\u65b9\\u5e93\\u3002<\\/p>\"],\"python3\":[\"Python3\",\"

\\u7248\\u672c\\uff1aPython 3.10<\\/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 2.13<\\/code><\\/p>\"],\"kotlin\":[\"Kotlin\",\"

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

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

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

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

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

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

Compile Options: --alwaysStrict --strictBindCallApply --strictFunctionTypes --target ES2020<\\/p>\"],\"racket\":[\"Racket\",\"

Racket CS<\\/a> v8.3<\\/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 24.2\"],\"elixir\":[\"Elixir\",\"Elixir 1.13.0 with Erlang\\/OTP 24.2\"]}", + "book": { + "id": "8", + "bookName": "《剑指 Offer(专项突击版)》", + "pressName": "电子工业出版社", + "source": "《剑指 Offer(专项突击版)》独家授权", + "shortDescription": "通行全球的程序员经典面试秘籍", + "fullDescription": "本书精选国内外名企高频面试题并深度拓展,系统地总结了程序员面试中必备的数据结构与算法知识,并以面试者及面试官的双向视角剖析考点与解题思路,适合所有正在准备面试的程序员阅读。", + "bookImgUrl": "https://pic.leetcode-cn.com/1626752512-sWgHof-image.png", + "pressImgUrl": "https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2020/02/11/logo-01.png", + "productUrl": "", + "__typename": "CategoryInfoNode" + }, + "isSubscribed": false, + "isDailyQuestion": false, + "dailyRecordStatus": null, + "editorType": "CKEDITOR", + "ugcQuestionId": null, + "style": "LEETCODE", + "exampleTestcases": "[1,2,3]\n[0]", + "__typename": "QuestionNode" + } + } +} \ No newline at end of file diff --git a/算法题(国内版)/originData/Y1VbOX.json b/算法题(国内版)/originData/Y1VbOX.json new file mode 100644 index 00000000..3d22dcba --- /dev/null +++ b/算法题(国内版)/originData/Y1VbOX.json @@ -0,0 +1,181 @@ +{ + "data": { + "question": { + "questionId": "1000367", + "questionFrontendId": "LCP 43", + "categoryTitle": "Algorithms", + "boundTopicId": 987424, + "title": "十字路口的交通", + "titleSlug": "Y1VbOX", + "content": "", + "translatedTitle": "十字路口的交通", + "translatedContent": "前往「力扣挑战赛」场馆的道路上,有一个拥堵的十字路口,该十字路口由两条双向两车道的路交叉构成。由于信号灯故障,交警需要手动指挥拥堵车辆。假定路口没有新的来车且一辆车从一个车道驶入另一个车道所需的时间恰好为一秒钟,长度为 4 的一维字符串数组 `directions` 中按照 **东、南、西、北** 顺序记录了四个方向从最靠近路口到最远离路口的车辆计划开往的方向。其中:\n- `\"E\"` 表示向东行驶;\n- `\"S\"` 表示向南行驶;\n- `\"W\"` 表示向西行驶;\n- `\"N\"` 表示向北行驶。\n\n交警每秒钟只能指挥各个车道距离路口最近的一辆车,且每次指挥需要满足如下规则:\n- 同一秒钟内,一个方向的车道只允许驶出一辆车;\n- 同一秒钟内,一个方向的车道只允许驶入一辆车;\n- 同一秒钟内,车辆的行驶路线不可相交。\n\n请返回最少需要几秒钟,该十字路口等候的车辆才能全部走完。\n\n各个车道驶出的车辆可能的行驶路线如图所示:\n\n\n![图片.png](https://pic.leetcode-cn.com/1630393755-gyPeMM-%E5%9B%BE%E7%89%87.png){:height=\"350px\"}\n\n**注意:**\n- 测试数据保证不会出现掉头行驶指令,即某一方向的行驶车辆计划开往的方向不会是当前车辆所在的车道的方向;\n- 表示堵塞车辆行驶方向的字符串仅用大写字母 `\"E\"`,`\"N\"`,`\"W\"`,`\"S\"` 表示。\n\n**示例 1:**\n>输入:`directions = [\"W\",\"N\",\"ES\",\"W\"]`\n>\n>输出:`2`\n>\n>解释:\n>第 1 秒:东西方向排在最前的车先行,剩余车辆状态 `[\"\",\"N\",\"S\",\"W\"]`;\n>第 2 秒:南、西、北方向的车行驶,路口无等待车辆;\n>因此最少需要 2 秒,返回 2。\n\n**示例 2:**\n>输入:`directions = [\"NS\",\"WE\",\"SE\",\"EW\"]`\n>\n>输出:`3`\n>\n>解释:\n>第 1 秒:四个方向排在最前的车均可驶出;\n>第 2 秒:东南方向的车驶出,剩余车辆状态 `[\"\",\"\",\"E\",\"W\"]`;\n>第 3 秒:西北方向的车驶出。\n\n\n**提示:**\n- `directions.length = 4`\n- `0 <= directions[i].length <= 20`\n", + "isPaidOnly": false, + "difficulty": "Hard", + "likes": 8, + "dislikes": 0, + "isLiked": null, + "similarQuestions": "[]", + "contributors": [ + { + "username": "LeetCode", + "profileUrl": "/u/leetcode", + "avatarUrl": "https://assets.leetcode-cn.com/aliyun-lc-upload/uploaded_files/2021/03/73c9f099-abbe-4d94-853f-f8abffd459cd/leetcode.png", + "__typename": "ContributorNode" + } + ], + "langToValidPlayground": "{\"cpp\": false, \"java\": true, \"python\": true, \"python3\": false, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"ruby\": false, \"bash\": false, \"swift\": false, \"golang\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"kotlin\": false, \"rust\": false, \"php\": false, \"typescript\": false, \"racket\": false, \"erlang\": false, \"elixir\": false}", + "topicTags": [ + { + "name": "Array", + "slug": "array", + "translatedName": "数组", + "__typename": "TopicTagNode" + }, + { + "name": "String", + "slug": "string", + "translatedName": "字符串", + "__typename": "TopicTagNode" + }, + { + "name": "Dynamic Programming", + "slug": "dynamic-programming", + "translatedName": "动态规划", + "__typename": "TopicTagNode" + } + ], + "companyTagStats": null, + "codeSnippets": [ + { + "lang": "C++", + "langSlug": "cpp", + "code": "class Solution {\npublic:\n int trafficCommand(vector& directions) {\n\n }\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Java", + "langSlug": "java", + "code": "class Solution {\n public int trafficCommand(String[] directions) {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Python", + "langSlug": "python", + "code": "class Solution(object):\n def trafficCommand(self, directions):\n \"\"\"\n :type directions: List[str]\n :rtype: int\n \"\"\"", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Python3", + "langSlug": "python3", + "code": "class Solution:\n def trafficCommand(self, directions: List[str]) -> int:", + "__typename": "CodeSnippetNode" + }, + { + "lang": "C", + "langSlug": "c", + "code": "\n\nint trafficCommand(char** directions, int directionsSize){\n\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "C#", + "langSlug": "csharp", + "code": "public class Solution {\n public int TrafficCommand(string[] directions) {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "JavaScript", + "langSlug": "javascript", + "code": "/**\n * @param {string[]} directions\n * @return {number}\n */\nvar trafficCommand = function(directions) {\n\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Ruby", + "langSlug": "ruby", + "code": "# @param {String[]} directions\n# @return {Integer}\ndef traffic_command(directions)\n\nend", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Swift", + "langSlug": "swift", + "code": "class Solution {\n func trafficCommand(_ directions: [String]) -> Int {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Go", + "langSlug": "golang", + "code": "func trafficCommand(directions []string) int {\n\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Scala", + "langSlug": "scala", + "code": "object Solution {\n def trafficCommand(directions: Array[String]): Int = {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Kotlin", + "langSlug": "kotlin", + "code": "class Solution {\n fun trafficCommand(directions: Array): Int {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Rust", + "langSlug": "rust", + "code": "impl Solution {\n pub fn traffic_command(directions: Vec) -> i32 {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "PHP", + "langSlug": "php", + "code": "class Solution {\n\n /**\n * @param String[] $directions\n * @return Integer\n */\n function trafficCommand($directions) {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "TypeScript", + "langSlug": "typescript", + "code": "function trafficCommand(directions: string[]): number {\n\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Racket", + "langSlug": "racket", + "code": "(define/contract (traffic-command directions)\n (-> (listof string?) exact-integer?)\n\n )", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Erlang", + "langSlug": "erlang", + "code": "-spec traffic_command(Directions :: [unicode:unicode_binary()]) -> integer().\ntraffic_command(Directions) ->\n .", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Elixir", + "langSlug": "elixir", + "code": "defmodule Solution do\n @spec traffic_command(directions :: [String.t]) :: integer\n def traffic_command(directions) do\n\n end\nend", + "__typename": "CodeSnippetNode" + } + ], + "stats": "{\"totalAccepted\": \"551\", \"totalSubmission\": \"1.2K\", \"totalAcceptedRaw\": 551, \"totalSubmissionRaw\": 1208, \"acRate\": \"45.6%\"}", + "hints": [], + "solution": null, + "status": null, + "sampleTestCase": "[\"W\",\"N\",\"ES\",\"W\"]", + "metaData": "{\"name\": \"trafficCommand\", \"params\": [{\"name\": \"directions\", \"type\": \"string[]\"}], \"return\": {\"type\": \"integer\"}}", + "judgerAvailable": true, + "judgeType": "large", + "mysqlSchemas": [], + "enableRunCode": true, + "envInfo": "{\"cpp\":[\"C++\",\"

\\u7248\\u672c\\uff1aclang 11<\\/code> \\u91c7\\u7528\\u6700\\u65b0C++ 17\\u6807\\u51c6\\u3002<\\/p>\\r\\n\\r\\n

\\u7f16\\u8bd1\\u65f6\\uff0c\\u5c06\\u4f1a\\u91c7\\u7528-O2<\\/code>\\u7ea7\\u4f18\\u5316\\u3002AddressSanitizer<\\/a> \\u4e5f\\u88ab\\u5f00\\u542f\\u6765\\u68c0\\u6d4bout-of-bounds<\\/code>\\u548cuse-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 17<\\/code>\\u3002\\u53ef\\u4ee5\\u4f7f\\u7528Java 8\\u7684\\u7279\\u6027\\u4f8b\\u5982\\uff0clambda expressions \\u548c stream API\\u3002<\\/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.12<\\/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 \\u5c06\\u57282020\\u5e74\\u540e\\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 8.2<\\/code>\\uff0c\\u91c7\\u7528GNU99\\u6807\\u51c6\\u3002<\\/p>\\r\\n\\r\\n

\\u7f16\\u8bd1\\u65f6\\uff0c\\u5c06\\u4f1a\\u91c7\\u7528-O1<\\/code>\\u7ea7\\u4f18\\u5316\\u3002 AddressSanitizer<\\/a>\\u4e5f\\u88ab\\u5f00\\u542f\\u6765\\u68c0\\u6d4bout-of-bounds<\\/code>\\u548cuse-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# 10<\\/a> \\u8fd0\\u884c\\u5728 .NET 6 \\u4e0a<\\/p>\\r\\n\\r\\n

\\u60a8\\u7684\\u4ee3\\u7801\\u5728\\u7f16\\u8bd1\\u65f6\\u9ed8\\u8ba4\\u5f00\\u542f\\u4e86debug\\u6807\\u8bb0(\\/debug:pdbonly<\\/code>)\\u3002<\\/p>\"],\"javascript\":[\"JavaScript\",\"

\\u7248\\u672c\\uff1aNode.js 16.13.2<\\/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<\\/a> \\u548c datastructures-js\\/queue<\\/a>\\u3002<\\/p>\"],\"ruby\":[\"Ruby\",\"

\\u4f7f\\u7528Ruby 3.1<\\/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 5.5.2<\\/code><\\/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.17<\\/code><\\/p>\\r\\n\\r\\n

\\u652f\\u6301 https:\\/\\/godoc.org\\/github.com\\/emirpasic\\/gods<\\/a> \\u7b2c\\u4e09\\u65b9\\u5e93\\u3002<\\/p>\"],\"python3\":[\"Python3\",\"

\\u7248\\u672c\\uff1aPython 3.10<\\/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 2.13<\\/code><\\/p>\"],\"kotlin\":[\"Kotlin\",\"

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

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

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

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

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

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

Compile Options: --alwaysStrict --strictBindCallApply --strictFunctionTypes --target ES2020<\\/p>\"],\"racket\":[\"Racket\",\"

Racket CS<\\/a> v8.3<\\/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 24.2\"],\"elixir\":[\"Elixir\",\"Elixir 1.13.0 with Erlang\\/OTP 24.2\"]}", + "book": null, + "isSubscribed": false, + "isDailyQuestion": false, + "dailyRecordStatus": null, + "editorType": "MARKDOWN", + "ugcQuestionId": null, + "style": "LEETCODE", + "exampleTestcases": "[\"W\",\"N\",\"ES\",\"W\"]\n[\"NS\",\"WE\",\"SE\",\"EW\"]", + "__typename": "QuestionNode" + } + } +} \ No newline at end of file diff --git a/算法题(国内版)/originData/bLyHh0.json b/算法题(国内版)/originData/bLyHh0.json new file mode 100644 index 00000000..dfde3f46 --- /dev/null +++ b/算法题(国内版)/originData/bLyHh0.json @@ -0,0 +1,198 @@ +{ + "data": { + "question": { + "questionId": "1000346", + "questionFrontendId": "剑指 Offer II 116", + "categoryTitle": "LCOF2", + "boundTopicId": 910434, + "title": "省份数量", + "titleSlug": "bLyHh0", + "content": "

English description is not available for the problem. Please switch to Chinese.

\n", + "translatedTitle": "省份数量", + "translatedContent": "
\n

n 个城市,其中一些彼此相连,另一些没有相连。如果城市 a 与城市 b 直接相连,且城市 b 与城市 c 直接相连,那么城市 a 与城市 c 间接相连。

\n\n

省份 是一组直接或间接相连的城市,组内不含其他没有相连的城市。

\n\n

给你一个 n x n 的矩阵 isConnected ,其中 isConnected[i][j] = 1 表示第 i 个城市和第 j 个城市直接相连,而 isConnected[i][j] = 0 表示二者不直接相连。

\n\n

返回矩阵中 省份 的数量。

\n\n

 

\n\n

示例 1:

\n\"\"\n
\n输入:isConnected = [[1,1,0],[1,1,0],[0,0,1]]\n输出:2\n
\n\n

示例 2:

\n\"\"\n
\n输入:isConnected = [[1,0,0],[0,1,0],[0,0,1]]\n输出:3\n
\n\n

 

\n\n

提示:

\n\n
    \n\t
  • 1 <= n <= 200
  • \n\t
  • n == isConnected.length
  • \n\t
  • n == isConnected[i].length
  • \n\t
  • isConnected[i][j]10
  • \n\t
  • isConnected[i][i] == 1
  • \n\t
  • isConnected[i][j] == isConnected[j][i]
  • \n
\n
\n\n

 

\n\n

注意:本题与主站 547 题相同: https://leetcode-cn.com/problems/number-of-provinces/

\n", + "isPaidOnly": false, + "difficulty": "Medium", + "likes": 25, + "dislikes": 0, + "isLiked": null, + "similarQuestions": "[]", + "contributors": [ + { + "username": "LeetCode", + "profileUrl": "/u/leetcode", + "avatarUrl": "https://assets.leetcode-cn.com/aliyun-lc-upload/uploaded_files/2021/03/73c9f099-abbe-4d94-853f-f8abffd459cd/leetcode.png", + "__typename": "ContributorNode" + } + ], + "langToValidPlayground": "{\"cpp\": false, \"java\": true, \"python\": true, \"python3\": false, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"ruby\": false, \"bash\": false, \"swift\": false, \"golang\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"kotlin\": false, \"rust\": false, \"php\": false, \"typescript\": false, \"racket\": false, \"erlang\": false, \"elixir\": false}", + "topicTags": [ + { + "name": "Depth-First Search", + "slug": "depth-first-search", + "translatedName": "深度优先搜索", + "__typename": "TopicTagNode" + }, + { + "name": "Breadth-First Search", + "slug": "breadth-first-search", + "translatedName": "广度优先搜索", + "__typename": "TopicTagNode" + }, + { + "name": "Union Find", + "slug": "union-find", + "translatedName": "并查集", + "__typename": "TopicTagNode" + }, + { + "name": "Graph", + "slug": "graph", + "translatedName": "图", + "__typename": "TopicTagNode" + } + ], + "companyTagStats": null, + "codeSnippets": [ + { + "lang": "C++", + "langSlug": "cpp", + "code": "class Solution {\npublic:\n int findCircleNum(vector>& isConnected) {\n\n }\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Java", + "langSlug": "java", + "code": "class Solution {\n public int findCircleNum(int[][] isConnected) {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Python", + "langSlug": "python", + "code": "class Solution(object):\n def findCircleNum(self, isConnected):\n \"\"\"\n :type isConnected: List[List[int]]\n :rtype: int\n \"\"\"", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Python3", + "langSlug": "python3", + "code": "class Solution:\n def findCircleNum(self, isConnected: List[List[int]]) -> int:", + "__typename": "CodeSnippetNode" + }, + { + "lang": "C", + "langSlug": "c", + "code": "\n\nint findCircleNum(int** isConnected, int isConnectedSize, int* isConnectedColSize){\n\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "C#", + "langSlug": "csharp", + "code": "public class Solution {\n public int FindCircleNum(int[][] isConnected) {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "JavaScript", + "langSlug": "javascript", + "code": "/**\n * @param {number[][]} isConnected\n * @return {number}\n */\nvar findCircleNum = function(isConnected) {\n\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Ruby", + "langSlug": "ruby", + "code": "# @param {Integer[][]} is_connected\n# @return {Integer}\ndef find_circle_num(is_connected)\n\nend", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Swift", + "langSlug": "swift", + "code": "class Solution {\n func findCircleNum(_ isConnected: [[Int]]) -> Int {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Go", + "langSlug": "golang", + "code": "func findCircleNum(isConnected [][]int) int {\n\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Scala", + "langSlug": "scala", + "code": "object Solution {\n def findCircleNum(isConnected: Array[Array[Int]]): Int = {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Kotlin", + "langSlug": "kotlin", + "code": "class Solution {\n fun findCircleNum(isConnected: Array): Int {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Rust", + "langSlug": "rust", + "code": "impl Solution {\n pub fn find_circle_num(is_connected: Vec>) -> i32 {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "PHP", + "langSlug": "php", + "code": "class Solution {\n\n /**\n * @param Integer[][] $isConnected\n * @return Integer\n */\n function findCircleNum($isConnected) {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "TypeScript", + "langSlug": "typescript", + "code": "function findCircleNum(isConnected: number[][]): number {\n\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Racket", + "langSlug": "racket", + "code": "(define/contract (find-circle-num isConnected)\n (-> (listof (listof exact-integer?)) exact-integer?)\n\n )", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Erlang", + "langSlug": "erlang", + "code": "-spec find_circle_num(IsConnected :: [[integer()]]) -> integer().\nfind_circle_num(IsConnected) ->\n .", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Elixir", + "langSlug": "elixir", + "code": "defmodule Solution do\n @spec find_circle_num(is_connected :: [[integer]]) :: integer\n def find_circle_num(is_connected) do\n\n end\nend", + "__typename": "CodeSnippetNode" + } + ], + "stats": "{\"totalAccepted\": \"8.2K\", \"totalSubmission\": \"12.3K\", \"totalAcceptedRaw\": 8185, \"totalSubmissionRaw\": 12260, \"acRate\": \"66.8%\"}", + "hints": [], + "solution": null, + "status": null, + "sampleTestCase": "[[1,1,0],[1,1,0],[0,0,1]]", + "metaData": "{\"name\": \"findCircleNum\", \"params\": [{\"name\": \"isConnected\", \"type\": \"integer[][]\"}], \"return\": {\"type\": \"integer\"}}", + "judgerAvailable": true, + "judgeType": "large", + "mysqlSchemas": [], + "enableRunCode": true, + "envInfo": "{\"cpp\":[\"C++\",\"

\\u7248\\u672c\\uff1aclang 11<\\/code> \\u91c7\\u7528\\u6700\\u65b0C++ 17\\u6807\\u51c6\\u3002<\\/p>\\r\\n\\r\\n

\\u7f16\\u8bd1\\u65f6\\uff0c\\u5c06\\u4f1a\\u91c7\\u7528-O2<\\/code>\\u7ea7\\u4f18\\u5316\\u3002AddressSanitizer<\\/a> \\u4e5f\\u88ab\\u5f00\\u542f\\u6765\\u68c0\\u6d4bout-of-bounds<\\/code>\\u548cuse-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 17<\\/code>\\u3002\\u53ef\\u4ee5\\u4f7f\\u7528Java 8\\u7684\\u7279\\u6027\\u4f8b\\u5982\\uff0clambda expressions \\u548c stream API\\u3002<\\/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.12<\\/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 \\u5c06\\u57282020\\u5e74\\u540e\\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 8.2<\\/code>\\uff0c\\u91c7\\u7528GNU99\\u6807\\u51c6\\u3002<\\/p>\\r\\n\\r\\n

\\u7f16\\u8bd1\\u65f6\\uff0c\\u5c06\\u4f1a\\u91c7\\u7528-O1<\\/code>\\u7ea7\\u4f18\\u5316\\u3002 AddressSanitizer<\\/a>\\u4e5f\\u88ab\\u5f00\\u542f\\u6765\\u68c0\\u6d4bout-of-bounds<\\/code>\\u548cuse-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# 10<\\/a> \\u8fd0\\u884c\\u5728 .NET 6 \\u4e0a<\\/p>\\r\\n\\r\\n

\\u60a8\\u7684\\u4ee3\\u7801\\u5728\\u7f16\\u8bd1\\u65f6\\u9ed8\\u8ba4\\u5f00\\u542f\\u4e86debug\\u6807\\u8bb0(\\/debug:pdbonly<\\/code>)\\u3002<\\/p>\"],\"javascript\":[\"JavaScript\",\"

\\u7248\\u672c\\uff1aNode.js 16.13.2<\\/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<\\/a> \\u548c datastructures-js\\/queue<\\/a>\\u3002<\\/p>\"],\"ruby\":[\"Ruby\",\"

\\u4f7f\\u7528Ruby 3.1<\\/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 5.5.2<\\/code><\\/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.17<\\/code><\\/p>\\r\\n\\r\\n

\\u652f\\u6301 https:\\/\\/godoc.org\\/github.com\\/emirpasic\\/gods<\\/a> \\u7b2c\\u4e09\\u65b9\\u5e93\\u3002<\\/p>\"],\"python3\":[\"Python3\",\"

\\u7248\\u672c\\uff1aPython 3.10<\\/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 2.13<\\/code><\\/p>\"],\"kotlin\":[\"Kotlin\",\"

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

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

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

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

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

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

Compile Options: --alwaysStrict --strictBindCallApply --strictFunctionTypes --target ES2020<\\/p>\"],\"racket\":[\"Racket\",\"

Racket CS<\\/a> v8.3<\\/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 24.2\"],\"elixir\":[\"Elixir\",\"Elixir 1.13.0 with Erlang\\/OTP 24.2\"]}", + "book": { + "id": "8", + "bookName": "《剑指 Offer(专项突击版)》", + "pressName": "电子工业出版社", + "source": "《剑指 Offer(专项突击版)》独家授权", + "shortDescription": "通行全球的程序员经典面试秘籍", + "fullDescription": "本书精选国内外名企高频面试题并深度拓展,系统地总结了程序员面试中必备的数据结构与算法知识,并以面试者及面试官的双向视角剖析考点与解题思路,适合所有正在准备面试的程序员阅读。", + "bookImgUrl": "https://pic.leetcode-cn.com/1626752512-sWgHof-image.png", + "pressImgUrl": "https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2020/02/11/logo-01.png", + "productUrl": "", + "__typename": "CategoryInfoNode" + }, + "isSubscribed": false, + "isDailyQuestion": false, + "dailyRecordStatus": null, + "editorType": "CKEDITOR", + "ugcQuestionId": null, + "style": "LEETCODE", + "exampleTestcases": "[[1,1,0],[1,1,0],[0,0,1]]\n[[1,0,0],[0,1,0],[0,0,1]]", + "__typename": "QuestionNode" + } + } +} \ No newline at end of file diff --git a/算法题(国内版)/originData/fHi6rV.json b/算法题(国内版)/originData/fHi6rV.json new file mode 100644 index 00000000..bfb231a0 --- /dev/null +++ b/算法题(国内版)/originData/fHi6rV.json @@ -0,0 +1,169 @@ +{ + "data": { + "question": { + "questionId": "1000370", + "questionFrontendId": "LCP 41", + "categoryTitle": "Algorithms", + "boundTopicId": 991681, + "title": "黑白翻转棋", + "titleSlug": "fHi6rV", + "content": "", + "translatedTitle": "黑白翻转棋", + "translatedContent": "在 `n*m` 大小的棋盘中,有黑白两种棋子,黑棋记作字母 `\"X\"`, 白棋记作字母 `\"O\"`,空余位置记作 `\".\"`。当落下的棋子与其他相同颜色的棋子在行、列或对角线完全包围(中间不存在空白位置)另一种颜色的棋子,则可以翻转这些棋子的颜色。\n\n\n\n![1.gif](https://pic.leetcode-cn.com/1630396029-eTgzpN-6da662e67368466a96d203f67bb6e793.gif){:height=170px}![2.gif](https://pic.leetcode-cn.com/1630396240-nMvdcc-8e4261afe9f60e05a4f740694b439b6b.gif){:height=170px}![3.gif](https://pic.leetcode-cn.com/1630396291-kEtzLL-6fcb682daeecb5c3f56eb88b23c81d33.gif){:height=170px}\n\n「力扣挑战赛」黑白翻转棋项目中,将提供给选手一个未形成可翻转棋子的棋盘残局,其状态记作 `chessboard`。若下一步可放置一枚黑棋,请问选手最多能翻转多少枚白棋。\n\n**注意:**\n- 若翻转白棋成黑棋后,棋盘上仍存在可以翻转的白棋,将可以 **继续** 翻转白棋\n- 输入数据保证初始棋盘状态无可以翻转的棋子且存在空余位置\n\n**示例 1:**\n> 输入:`chessboard = [\"....X.\",\"....X.\",\"XOOO..\",\"......\",\"......\"]`\n> \n> 输出:`3`\n> \n> 解释:\n> 可以选择下在 `[2,4]` 处,能够翻转白方三枚棋子。\n\n**示例 2:**\n> 输入:`chessboard = [\".X.\",\".O.\",\"XO.\"]`\n> \n> 输出:`2`\n> \n> 解释:\n> 可以选择下在 `[2,2]` 处,能够翻转白方两枚棋子。\n![2126c1d21b1b9a9924c639d449cc6e65.gif](https://pic.leetcode-cn.com/1626683255-OBtBud-2126c1d21b1b9a9924c639d449cc6e65.gif)\n\n**示例 3:**\n> 输入:`chessboard = [\".......\",\".......\",\".......\",\"X......\",\".O.....\",\"..O....\",\"....OOX\"]`\n> \n> 输出:`4`\n> \n> 解释:\n> 可以选择下在 `[6,3]` 处,能够翻转白方四枚棋子。\n![803f2f04098b6174397d6c696f54d709.gif](https://pic.leetcode-cn.com/1630393770-Puyked-803f2f04098b6174397d6c696f54d709.gif)\n\n\n\n**提示:**\n- `1 <= chessboard.length, chessboard[i].length <= 8`\n- `chessboard[i]` 仅包含 `\".\"、\"O\"` 和 `\"X\"`", + "isPaidOnly": false, + "difficulty": "Medium", + "likes": 4, + "dislikes": 0, + "isLiked": null, + "similarQuestions": "[]", + "contributors": [ + { + "username": "LeetCode", + "profileUrl": "/u/leetcode", + "avatarUrl": "https://assets.leetcode-cn.com/aliyun-lc-upload/uploaded_files/2021/03/73c9f099-abbe-4d94-853f-f8abffd459cd/leetcode.png", + "__typename": "ContributorNode" + } + ], + "langToValidPlayground": "{\"cpp\": false, \"java\": true, \"python\": true, \"python3\": false, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"ruby\": false, \"bash\": false, \"swift\": false, \"golang\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"kotlin\": false, \"rust\": false, \"php\": false, \"typescript\": false, \"racket\": false, \"erlang\": false, \"elixir\": false}", + "topicTags": [ + { + "name": "Breadth-First Search", + "slug": "breadth-first-search", + "translatedName": "广度优先搜索", + "__typename": "TopicTagNode" + }, + { + "name": "Array", + "slug": "array", + "translatedName": "数组", + "__typename": "TopicTagNode" + }, + { + "name": "Matrix", + "slug": "matrix", + "translatedName": "矩阵", + "__typename": "TopicTagNode" + } + ], + "companyTagStats": null, + "codeSnippets": [ + { + "lang": "C++", + "langSlug": "cpp", + "code": "class Solution {\npublic:\n int flipChess(vector& chessboard) {\n\n }\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Java", + "langSlug": "java", + "code": "class Solution {\n public int flipChess(String[] chessboard) {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Python", + "langSlug": "python", + "code": "class Solution(object):\n def flipChess(self, chessboard):\n \"\"\"\n :type chessboard: List[str]\n :rtype: int\n \"\"\"", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Python3", + "langSlug": "python3", + "code": "class Solution:\n def flipChess(self, chessboard: List[str]) -> int:", + "__typename": "CodeSnippetNode" + }, + { + "lang": "C", + "langSlug": "c", + "code": "\n\nint flipChess(char** chessboard, int chessboardSize){\n\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "C#", + "langSlug": "csharp", + "code": "public class Solution {\n public int FlipChess(string[] chessboard) {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "JavaScript", + "langSlug": "javascript", + "code": "/**\n * @param {string[]} chessboard\n * @return {number}\n */\nvar flipChess = function(chessboard) {\n\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Ruby", + "langSlug": "ruby", + "code": "# @param {String[]} chessboard\n# @return {Integer}\ndef flip_chess(chessboard)\n\nend", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Swift", + "langSlug": "swift", + "code": "class Solution {\n func flipChess(_ chessboard: [String]) -> Int {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Go", + "langSlug": "golang", + "code": "func flipChess(chessboard []string) int {\n\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Scala", + "langSlug": "scala", + "code": "object Solution {\n def flipChess(chessboard: Array[String]): Int = {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Kotlin", + "langSlug": "kotlin", + "code": "class Solution {\n fun flipChess(chessboard: Array): Int {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Rust", + "langSlug": "rust", + "code": "impl Solution {\n pub fn flip_chess(chessboard: Vec) -> i32 {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "PHP", + "langSlug": "php", + "code": "class Solution {\n\n /**\n * @param String[] $chessboard\n * @return Integer\n */\n function flipChess($chessboard) {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "TypeScript", + "langSlug": "typescript", + "code": "function flipChess(chessboard: string[]): number {\n\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Racket", + "langSlug": "racket", + "code": "(define/contract (flip-chess chessboard)\n (-> (listof string?) exact-integer?)\n\n )", + "__typename": "CodeSnippetNode" + } + ], + "stats": "{\"totalAccepted\": \"1.6K\", \"totalSubmission\": \"3.6K\", \"totalAcceptedRaw\": 1608, \"totalSubmissionRaw\": 3613, \"acRate\": \"44.5%\"}", + "hints": [], + "solution": null, + "status": null, + "sampleTestCase": "[\"....X.\",\"....X.\",\"XOOO..\",\"......\",\"......\"]", + "metaData": "{\"name\": \"flipChess\", \"params\": [{\"name\": \"chessboard\", \"type\": \"string[]\"}], \"return\": {\"type\": \"integer\"}}", + "judgerAvailable": true, + "judgeType": "large", + "mysqlSchemas": [], + "enableRunCode": true, + "envInfo": "{\"cpp\":[\"C++\",\"

\\u7248\\u672c\\uff1aclang 11<\\/code> \\u91c7\\u7528\\u6700\\u65b0C++ 17\\u6807\\u51c6\\u3002<\\/p>\\r\\n\\r\\n

\\u7f16\\u8bd1\\u65f6\\uff0c\\u5c06\\u4f1a\\u91c7\\u7528-O2<\\/code>\\u7ea7\\u4f18\\u5316\\u3002AddressSanitizer<\\/a> \\u4e5f\\u88ab\\u5f00\\u542f\\u6765\\u68c0\\u6d4bout-of-bounds<\\/code>\\u548cuse-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 17<\\/code>\\u3002\\u53ef\\u4ee5\\u4f7f\\u7528Java 8\\u7684\\u7279\\u6027\\u4f8b\\u5982\\uff0clambda expressions \\u548c stream API\\u3002<\\/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.12<\\/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 \\u5c06\\u57282020\\u5e74\\u540e\\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 8.2<\\/code>\\uff0c\\u91c7\\u7528GNU99\\u6807\\u51c6\\u3002<\\/p>\\r\\n\\r\\n

\\u7f16\\u8bd1\\u65f6\\uff0c\\u5c06\\u4f1a\\u91c7\\u7528-O1<\\/code>\\u7ea7\\u4f18\\u5316\\u3002 AddressSanitizer<\\/a>\\u4e5f\\u88ab\\u5f00\\u542f\\u6765\\u68c0\\u6d4bout-of-bounds<\\/code>\\u548cuse-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# 10<\\/a> \\u8fd0\\u884c\\u5728 .NET 6 \\u4e0a<\\/p>\\r\\n\\r\\n

\\u60a8\\u7684\\u4ee3\\u7801\\u5728\\u7f16\\u8bd1\\u65f6\\u9ed8\\u8ba4\\u5f00\\u542f\\u4e86debug\\u6807\\u8bb0(\\/debug:pdbonly<\\/code>)\\u3002<\\/p>\"],\"javascript\":[\"JavaScript\",\"

\\u7248\\u672c\\uff1aNode.js 16.13.2<\\/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<\\/a> \\u548c datastructures-js\\/queue<\\/a>\\u3002<\\/p>\"],\"ruby\":[\"Ruby\",\"

\\u4f7f\\u7528Ruby 3.1<\\/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 5.5.2<\\/code><\\/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.17<\\/code><\\/p>\\r\\n\\r\\n

\\u652f\\u6301 https:\\/\\/godoc.org\\/github.com\\/emirpasic\\/gods<\\/a> \\u7b2c\\u4e09\\u65b9\\u5e93\\u3002<\\/p>\"],\"python3\":[\"Python3\",\"

\\u7248\\u672c\\uff1aPython 3.10<\\/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 2.13<\\/code><\\/p>\"],\"kotlin\":[\"Kotlin\",\"

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

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

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

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

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

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

Compile Options: --alwaysStrict --strictBindCallApply --strictFunctionTypes --target ES2020<\\/p>\"],\"racket\":[\"Racket\",\"

Racket CS<\\/a> v8.3<\\/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>\"]}", + "book": null, + "isSubscribed": false, + "isDailyQuestion": false, + "dailyRecordStatus": null, + "editorType": "MARKDOWN", + "ugcQuestionId": null, + "style": "LEETCODE", + "exampleTestcases": "[\"....X.\",\"....X.\",\"XOOO..\",\"......\",\"......\"]\n[\".X.\",\".O.\",\"XO.\"]\n[\".......\",\".......\",\".......\",\"X......\",\".O.....\",\"..O....\",\"....OOX\"]", + "__typename": "QuestionNode" + } + } +} \ No newline at end of file diff --git a/算法题(国内版)/originData/fsa7oZ.json b/算法题(国内版)/originData/fsa7oZ.json new file mode 100644 index 00000000..d95b10d8 --- /dev/null +++ b/算法题(国内版)/originData/fsa7oZ.json @@ -0,0 +1,187 @@ +{ + "data": { + "question": { + "questionId": "1000374", + "questionFrontendId": "LCP 48", + "categoryTitle": "Algorithms", + "boundTopicId": 1016614, + "title": "无限棋局", + "titleSlug": "fsa7oZ", + "content": "", + "translatedTitle": "无限棋局", + "translatedContent": "小力正在通过残局练习来备战「力扣挑战赛」中的「五子棋」项目,他想请你能帮他预测当前残局的输赢情况。棋盘中的棋子分布信息记录于二维数组 `pieces` 中,其中 `pieces[i] = [x,y,color]` 表示第 `i` 枚棋子的横坐标为 `x`,纵坐标为 `y`,棋子颜色为 `color`(`0` 表示黑棋,`1` 表示白棋)。假如黑棋先行,并且黑棋和白棋都按最优策略落子,请你求出当前棋局在三步(按 **黑、白、黑** 的落子顺序)之内的输赢情况(三步之内先构成同行、列或对角线连续同颜色的至少 5 颗即为获胜):\n- 黑棋胜, 请返回 `\"Black\"`\n- 白棋胜, 请返回 `\"White\"`\n- 仍无胜者, 请返回 `\"None\"`\n\n**注意:** \n- 和传统的五子棋项目不同,「力扣挑战赛」中的「五子棋」项目 **不存在边界限制**,即可在 **任意位置** 落子;\n- 黑棋和白棋均按 3 步内的输赢情况进行最优策略的选择\n- 测试数据保证所给棋局目前无胜者;\n- 测试数据保证不会存在坐标一样的棋子。\n\n**示例 1:**\n> 输入:\n> `pieces = [[0,0,1],[1,1,1],[2,2,0]]`\n>\n> 输出:`\"None\"`\n>\n> 解释:无论黑、白棋以何种方式落子,三步以内都不会产生胜者。\n\n**示例 2:**\n> 输入:\n> `pieces = [[1,2,1],[1,4,1],[1,5,1],[2,1,0],[2,3,0],[2,4,0],[3,2,1],[3,4,0],[4,2,1],[5,2,1]]`\n>\n> 输出:`\"Black\"`\n>\n> 解释:三步之内黑棋必胜,以下是一种可能的落子情况:\n>![902b87df29998b1c181146c8fdb3a4b6.gif](https://pic.leetcode-cn.com/1629800639-KabOfY-902b87df29998b1c181146c8fdb3a4b6.gif){:width=\"300px\"}\n\n\n\n**提示:**\n- `0 <= pieces.length <= 1000`\n- `pieces[i].length = 3`\n- `-10^9 <= pieces[i][0], pieces[i][1] <=10^9` \n- `0 <= pieces[i][2] <=1`\n", + "isPaidOnly": false, + "difficulty": "Hard", + "likes": 8, + "dislikes": 0, + "isLiked": null, + "similarQuestions": "[]", + "contributors": [ + { + "username": "LeetCode", + "profileUrl": "/u/leetcode", + "avatarUrl": "https://assets.leetcode-cn.com/aliyun-lc-upload/uploaded_files/2021/03/73c9f099-abbe-4d94-853f-f8abffd459cd/leetcode.png", + "__typename": "ContributorNode" + } + ], + "langToValidPlayground": "{\"cpp\": false, \"java\": true, \"python\": true, \"python3\": false, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"ruby\": false, \"bash\": false, \"swift\": false, \"golang\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"kotlin\": false, \"rust\": false, \"php\": false, \"typescript\": false, \"racket\": false, \"erlang\": false, \"elixir\": false}", + "topicTags": [ + { + "name": "Array", + "slug": "array", + "translatedName": "数组", + "__typename": "TopicTagNode" + }, + { + "name": "Math", + "slug": "math", + "translatedName": "数学", + "__typename": "TopicTagNode" + }, + { + "name": "Enumeration", + "slug": "enumeration", + "translatedName": "枚举", + "__typename": "TopicTagNode" + }, + { + "name": "Game Theory", + "slug": "game-theory", + "translatedName": "博弈", + "__typename": "TopicTagNode" + } + ], + "companyTagStats": null, + "codeSnippets": [ + { + "lang": "C++", + "langSlug": "cpp", + "code": "class Solution {\npublic:\n string gobang(vector>& pieces) {\n\n }\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Java", + "langSlug": "java", + "code": "class Solution {\n public String gobang(int[][] pieces) {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Python", + "langSlug": "python", + "code": "class Solution(object):\n def gobang(self, pieces):\n \"\"\"\n :type pieces: List[List[int]]\n :rtype: str\n \"\"\"", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Python3", + "langSlug": "python3", + "code": "class Solution:\n def gobang(self, pieces: List[List[int]]) -> str:", + "__typename": "CodeSnippetNode" + }, + { + "lang": "C", + "langSlug": "c", + "code": "\n\nchar* gobang(int** pieces, int piecesSize, int* piecesColSize){\n\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "C#", + "langSlug": "csharp", + "code": "public class Solution {\n public string Gobang(int[][] pieces) {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "JavaScript", + "langSlug": "javascript", + "code": "/**\n * @param {number[][]} pieces\n * @return {string}\n */\nvar gobang = function(pieces) {\n\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Ruby", + "langSlug": "ruby", + "code": "# @param {Integer[][]} pieces\n# @return {String}\ndef gobang(pieces)\n\nend", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Swift", + "langSlug": "swift", + "code": "class Solution {\n func gobang(_ pieces: [[Int]]) -> String {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Go", + "langSlug": "golang", + "code": "func gobang(pieces [][]int) string {\n\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Scala", + "langSlug": "scala", + "code": "object Solution {\n def gobang(pieces: Array[Array[Int]]): String = {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Kotlin", + "langSlug": "kotlin", + "code": "class Solution {\n fun gobang(pieces: Array): String {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Rust", + "langSlug": "rust", + "code": "impl Solution {\n pub fn gobang(pieces: Vec>) -> String {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "PHP", + "langSlug": "php", + "code": "class Solution {\n\n /**\n * @param Integer[][] $pieces\n * @return String\n */\n function gobang($pieces) {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "TypeScript", + "langSlug": "typescript", + "code": "function gobang(pieces: number[][]): string {\n\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Racket", + "langSlug": "racket", + "code": "(define/contract (gobang pieces)\n (-> (listof (listof exact-integer?)) string?)\n\n )", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Erlang", + "langSlug": "erlang", + "code": "-spec gobang(Pieces :: [[integer()]]) -> unicode:unicode_binary().\ngobang(Pieces) ->\n .", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Elixir", + "langSlug": "elixir", + "code": "defmodule Solution do\n @spec gobang(pieces :: [[integer]]) :: String.t\n def gobang(pieces) do\n\n end\nend", + "__typename": "CodeSnippetNode" + } + ], + "stats": "{\"totalAccepted\": \"483\", \"totalSubmission\": \"2.4K\", \"totalAcceptedRaw\": 483, \"totalSubmissionRaw\": 2384, \"acRate\": \"20.3%\"}", + "hints": [], + "solution": null, + "status": null, + "sampleTestCase": "[[0,0,1],[1,1,1],[2,2,0]]", + "metaData": "{\"name\": \"gobang\", \"params\": [{\"name\": \"pieces\", \"type\": \"integer[][]\"}], \"return\": {\"type\": \"string\"}}", + "judgerAvailable": true, + "judgeType": "large", + "mysqlSchemas": [], + "enableRunCode": true, + "envInfo": "{\"cpp\":[\"C++\",\"

\\u7248\\u672c\\uff1aclang 11<\\/code> \\u91c7\\u7528\\u6700\\u65b0C++ 17\\u6807\\u51c6\\u3002<\\/p>\\r\\n\\r\\n

\\u7f16\\u8bd1\\u65f6\\uff0c\\u5c06\\u4f1a\\u91c7\\u7528-O2<\\/code>\\u7ea7\\u4f18\\u5316\\u3002AddressSanitizer<\\/a> \\u4e5f\\u88ab\\u5f00\\u542f\\u6765\\u68c0\\u6d4bout-of-bounds<\\/code>\\u548cuse-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 17<\\/code>\\u3002\\u53ef\\u4ee5\\u4f7f\\u7528Java 8\\u7684\\u7279\\u6027\\u4f8b\\u5982\\uff0clambda expressions \\u548c stream API\\u3002<\\/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.12<\\/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 \\u5c06\\u57282020\\u5e74\\u540e\\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 8.2<\\/code>\\uff0c\\u91c7\\u7528GNU99\\u6807\\u51c6\\u3002<\\/p>\\r\\n\\r\\n

\\u7f16\\u8bd1\\u65f6\\uff0c\\u5c06\\u4f1a\\u91c7\\u7528-O1<\\/code>\\u7ea7\\u4f18\\u5316\\u3002 AddressSanitizer<\\/a>\\u4e5f\\u88ab\\u5f00\\u542f\\u6765\\u68c0\\u6d4bout-of-bounds<\\/code>\\u548cuse-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# 10<\\/a> \\u8fd0\\u884c\\u5728 .NET 6 \\u4e0a<\\/p>\\r\\n\\r\\n

\\u60a8\\u7684\\u4ee3\\u7801\\u5728\\u7f16\\u8bd1\\u65f6\\u9ed8\\u8ba4\\u5f00\\u542f\\u4e86debug\\u6807\\u8bb0(\\/debug:pdbonly<\\/code>)\\u3002<\\/p>\"],\"javascript\":[\"JavaScript\",\"

\\u7248\\u672c\\uff1aNode.js 16.13.2<\\/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<\\/a> \\u548c datastructures-js\\/queue<\\/a>\\u3002<\\/p>\"],\"ruby\":[\"Ruby\",\"

\\u4f7f\\u7528Ruby 3.1<\\/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 5.5.2<\\/code><\\/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.17<\\/code><\\/p>\\r\\n\\r\\n

\\u652f\\u6301 https:\\/\\/godoc.org\\/github.com\\/emirpasic\\/gods<\\/a> \\u7b2c\\u4e09\\u65b9\\u5e93\\u3002<\\/p>\"],\"python3\":[\"Python3\",\"

\\u7248\\u672c\\uff1aPython 3.10<\\/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 2.13<\\/code><\\/p>\"],\"kotlin\":[\"Kotlin\",\"

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

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

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

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

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

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

Compile Options: --alwaysStrict --strictBindCallApply --strictFunctionTypes --target ES2020<\\/p>\"],\"racket\":[\"Racket\",\"

Racket CS<\\/a> v8.3<\\/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 24.2\"],\"elixir\":[\"Elixir\",\"Elixir 1.13.0 with Erlang\\/OTP 24.2\"]}", + "book": null, + "isSubscribed": false, + "isDailyQuestion": false, + "dailyRecordStatus": null, + "editorType": "MARKDOWN", + "ugcQuestionId": null, + "style": "LEETCODE", + "exampleTestcases": "[[0,0,1],[1,1,1],[2,2,0]]\n[[1,2,1],[1,4,1],[1,5,1],[2,1,0],[2,3,0],[2,4,0],[3,2,1],[3,4,0],[4,2,1],[5,2,1]]", + "__typename": "QuestionNode" + } + } +} \ No newline at end of file diff --git a/算法题(国内版)/originData/kplEvH.json b/算法题(国内版)/originData/kplEvH.json new file mode 100644 index 00000000..459b5b41 --- /dev/null +++ b/算法题(国内版)/originData/kplEvH.json @@ -0,0 +1,187 @@ +{ + "data": { + "question": { + "questionId": "1000375", + "questionFrontendId": "LCP 45", + "categoryTitle": "Algorithms", + "boundTopicId": 1016617, + "title": "自行车炫技赛场", + "titleSlug": "kplEvH", + "content": "", + "translatedTitle": "自行车炫技赛场", + "translatedContent": "「力扣挑战赛」中 `N*M` 大小的自行车炫技赛场的场地由一片连绵起伏的上下坡组成,场地的高度值记录于二维数组 `terrain` 中,场地的减速值记录于二维数组 `obstacle` 中。\n- 若选手骑着自行车从高度为 `h1` 且减速值为 `o1` 的位置到高度为 `h2` 且减速值为 `o2` 的相邻位置(上下左右四个方向),速度变化值为 `h1-h2-o2`(负值减速,正值增速)。\n\n选手初始位于坐标 `position` 处且初始速度为 1,请问选手可以刚好到其他哪些位置时速度依旧为 1。请以二维数组形式返回这些位置。若有多个位置则按行坐标升序排列,若有多个位置行坐标相同则按列坐标升序排列。\n\n**注意:** 骑行过程中速度不能为零或负值\n\n**示例 1:**\n> 输入\b:`position = [0,0], terrain = [[0,0],[0,0]], obstacle = [[0,0],[0,0]]`\n> \n> 输出:`[[0,1],[1,0],[1,1]]`\n> \n> 解释:\n> 由于当前场地属于平地,根据上面的规则,选手从`[0,0]`的位置出发都能刚好在其他处的位置速度为 1。\n\n**示例 2:**\n> 输入\b:`position = [1,1], terrain = [[5,0],[0,6]], obstacle = [[0,6],[7,0]]`\n> \n> 输出:`[[0,1]]`\n> \n> 解释:\n> 选手从 `[1,1]` 处的位置出发,到 `[0,1]` 处的位置时恰好速度为 1。\n\n\n**提示:**\n- `n == terrain.length == obstacle.length`\n- `m == terrain[i].length == obstacle[i].length`\n- `1 <= n <= 100`\n- `1 <= m <= 100`\n- `0 <= terrain[i][j], obstacle[i][j] <= 100`\n- `position.length == 2`\n- `0 <= position[0] < n`\n- `0 <= position[1] < m`", + "isPaidOnly": false, + "difficulty": "Medium", + "likes": 6, + "dislikes": 0, + "isLiked": null, + "similarQuestions": "[]", + "contributors": [ + { + "username": "LeetCode", + "profileUrl": "/u/leetcode", + "avatarUrl": "https://assets.leetcode-cn.com/aliyun-lc-upload/uploaded_files/2021/03/73c9f099-abbe-4d94-853f-f8abffd459cd/leetcode.png", + "__typename": "ContributorNode" + } + ], + "langToValidPlayground": "{\"cpp\": false, \"java\": true, \"python\": true, \"python3\": false, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"ruby\": false, \"bash\": false, \"swift\": false, \"golang\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"kotlin\": false, \"rust\": false, \"php\": false, \"typescript\": false, \"racket\": false, \"erlang\": false, \"elixir\": false}", + "topicTags": [ + { + "name": "Depth-First Search", + "slug": "depth-first-search", + "translatedName": "深度优先搜索", + "__typename": "TopicTagNode" + }, + { + "name": "Breadth-First Search", + "slug": "breadth-first-search", + "translatedName": "广度优先搜索", + "__typename": "TopicTagNode" + }, + { + "name": "Memoization", + "slug": "memoization", + "translatedName": "记忆化搜索", + "__typename": "TopicTagNode" + }, + { + "name": "Array", + "slug": "array", + "translatedName": "数组", + "__typename": "TopicTagNode" + }, + { + "name": "Dynamic Programming", + "slug": "dynamic-programming", + "translatedName": "动态规划", + "__typename": "TopicTagNode" + }, + { + "name": "Matrix", + "slug": "matrix", + "translatedName": "矩阵", + "__typename": "TopicTagNode" + } + ], + "companyTagStats": null, + "codeSnippets": [ + { + "lang": "C++", + "langSlug": "cpp", + "code": "class Solution {\npublic:\n vector> bicycleYard(vector& position, vector>& terrain, vector>& obstacle) {\n\n }\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Java", + "langSlug": "java", + "code": "class Solution {\n public int[][] bicycleYard(int[] position, int[][] terrain, int[][] obstacle) {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Python", + "langSlug": "python", + "code": "class Solution(object):\n def bicycleYard(self, position, terrain, obstacle):\n \"\"\"\n :type position: List[int]\n :type terrain: List[List[int]]\n :type obstacle: List[List[int]]\n :rtype: List[List[int]]\n \"\"\"", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Python3", + "langSlug": "python3", + "code": "class Solution:\n def bicycleYard(self, position: List[int], terrain: List[List[int]], obstacle: List[List[int]]) -> List[List[int]]:", + "__typename": "CodeSnippetNode" + }, + { + "lang": "C", + "langSlug": "c", + "code": "\n\n/**\n * Return an array of arrays of size *returnSize.\n * The sizes of the arrays are returned as *returnColumnSizes array.\n * Note: Both returned array and *columnSizes array must be malloced, assume caller calls free().\n */\nint** bicycleYard(int* position, int positionSize, int** terrain, int terrainSize, int* terrainColSize, int** obstacle, int obstacleSize, int* obstacleColSize, int* returnSize, int** returnColumnSizes){\n\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "C#", + "langSlug": "csharp", + "code": "public class Solution {\n public int[][] BicycleYard(int[] position, int[][] terrain, int[][] obstacle) {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "JavaScript", + "langSlug": "javascript", + "code": "/**\n * @param {number[]} position\n * @param {number[][]} terrain\n * @param {number[][]} obstacle\n * @return {number[][]}\n */\nvar bicycleYard = function(position, terrain, obstacle) {\n\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Ruby", + "langSlug": "ruby", + "code": "# @param {Integer[]} position\n# @param {Integer[][]} terrain\n# @param {Integer[][]} obstacle\n# @return {Integer[][]}\ndef bicycle_yard(position, terrain, obstacle)\n\nend", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Swift", + "langSlug": "swift", + "code": "class Solution {\n func bicycleYard(_ position: [Int], _ terrain: [[Int]], _ obstacle: [[Int]]) -> [[Int]] {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Go", + "langSlug": "golang", + "code": "func bicycleYard(position []int, terrain [][]int, obstacle [][]int) [][]int {\n\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Scala", + "langSlug": "scala", + "code": "object Solution {\n def bicycleYard(position: Array[Int], terrain: Array[Array[Int]], obstacle: Array[Array[Int]]): Array[Array[Int]] = {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Kotlin", + "langSlug": "kotlin", + "code": "class Solution {\n fun bicycleYard(position: IntArray, terrain: Array, obstacle: Array): Array {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Rust", + "langSlug": "rust", + "code": "impl Solution {\n pub fn bicycle_yard(position: Vec, terrain: Vec>, obstacle: Vec>) -> Vec> {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "PHP", + "langSlug": "php", + "code": "class Solution {\n\n /**\n * @param Integer[] $position\n * @param Integer[][] $terrain\n * @param Integer[][] $obstacle\n * @return Integer[][]\n */\n function bicycleYard($position, $terrain, $obstacle) {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "TypeScript", + "langSlug": "typescript", + "code": "function bicycleYard(position: number[], terrain: number[][], obstacle: number[][]): number[][] {\n\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Racket", + "langSlug": "racket", + "code": "(define/contract (bicycle-yard position terrain obstacle)\n (-> (listof exact-integer?) (listof (listof exact-integer?)) (listof (listof exact-integer?)) (listof (listof exact-integer?)))\n\n )", + "__typename": "CodeSnippetNode" + } + ], + "stats": "{\"totalAccepted\": \"1.5K\", \"totalSubmission\": \"6.6K\", \"totalAcceptedRaw\": 1461, \"totalSubmissionRaw\": 6554, \"acRate\": \"22.3%\"}", + "hints": [], + "solution": null, + "status": null, + "sampleTestCase": "[0,0]\n[[0,0],[0,0]]\n[[0,0],[0,0]]", + "metaData": "{\"name\": \"bicycleYard\", \"params\": [{\"name\": \"position\", \"type\": \"integer[]\"}, {\"name\": \"terrain\", \"type\": \"integer[][]\"}, {\"name\": \"obstacle\", \"type\": \"integer[][]\"}], \"return\": {\"type\": \"integer[][]\"}}", + "judgerAvailable": true, + "judgeType": "large", + "mysqlSchemas": [], + "enableRunCode": true, + "envInfo": "{\"cpp\":[\"C++\",\"

\\u7248\\u672c\\uff1aclang 11<\\/code> \\u91c7\\u7528\\u6700\\u65b0C++ 17\\u6807\\u51c6\\u3002<\\/p>\\r\\n\\r\\n

\\u7f16\\u8bd1\\u65f6\\uff0c\\u5c06\\u4f1a\\u91c7\\u7528-O2<\\/code>\\u7ea7\\u4f18\\u5316\\u3002AddressSanitizer<\\/a> \\u4e5f\\u88ab\\u5f00\\u542f\\u6765\\u68c0\\u6d4bout-of-bounds<\\/code>\\u548cuse-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 17<\\/code>\\u3002\\u53ef\\u4ee5\\u4f7f\\u7528Java 8\\u7684\\u7279\\u6027\\u4f8b\\u5982\\uff0clambda expressions \\u548c stream API\\u3002<\\/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.12<\\/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 \\u5c06\\u57282020\\u5e74\\u540e\\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 8.2<\\/code>\\uff0c\\u91c7\\u7528GNU99\\u6807\\u51c6\\u3002<\\/p>\\r\\n\\r\\n

\\u7f16\\u8bd1\\u65f6\\uff0c\\u5c06\\u4f1a\\u91c7\\u7528-O1<\\/code>\\u7ea7\\u4f18\\u5316\\u3002 AddressSanitizer<\\/a>\\u4e5f\\u88ab\\u5f00\\u542f\\u6765\\u68c0\\u6d4bout-of-bounds<\\/code>\\u548cuse-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# 10<\\/a> \\u8fd0\\u884c\\u5728 .NET 6 \\u4e0a<\\/p>\\r\\n\\r\\n

\\u60a8\\u7684\\u4ee3\\u7801\\u5728\\u7f16\\u8bd1\\u65f6\\u9ed8\\u8ba4\\u5f00\\u542f\\u4e86debug\\u6807\\u8bb0(\\/debug:pdbonly<\\/code>)\\u3002<\\/p>\"],\"javascript\":[\"JavaScript\",\"

\\u7248\\u672c\\uff1aNode.js 16.13.2<\\/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<\\/a> \\u548c datastructures-js\\/queue<\\/a>\\u3002<\\/p>\"],\"ruby\":[\"Ruby\",\"

\\u4f7f\\u7528Ruby 3.1<\\/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 5.5.2<\\/code><\\/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.17<\\/code><\\/p>\\r\\n\\r\\n

\\u652f\\u6301 https:\\/\\/godoc.org\\/github.com\\/emirpasic\\/gods<\\/a> \\u7b2c\\u4e09\\u65b9\\u5e93\\u3002<\\/p>\"],\"python3\":[\"Python3\",\"

\\u7248\\u672c\\uff1aPython 3.10<\\/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 2.13<\\/code><\\/p>\"],\"kotlin\":[\"Kotlin\",\"

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

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

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

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

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

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

Compile Options: --alwaysStrict --strictBindCallApply --strictFunctionTypes --target ES2020<\\/p>\"],\"racket\":[\"Racket\",\"

Racket CS<\\/a> v8.3<\\/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>\"]}", + "book": null, + "isSubscribed": false, + "isDailyQuestion": false, + "dailyRecordStatus": null, + "editorType": "MARKDOWN", + "ugcQuestionId": null, + "style": "LEETCODE", + "exampleTestcases": "[0,0]\n[[0,0],[0,0]]\n[[0,0],[0,0]]\n[1,1]\n[[5,0],[0,6]]\n[[0,6],[7,0]]", + "__typename": "QuestionNode" + } + } +} \ No newline at end of file diff --git a/算法题(国内版)/originData/oPs9Bm.json b/算法题(国内版)/originData/oPs9Bm.json new file mode 100644 index 00000000..7b9b48a0 --- /dev/null +++ b/算法题(国内版)/originData/oPs9Bm.json @@ -0,0 +1,175 @@ +{ + "data": { + "question": { + "questionId": "1000361", + "questionFrontendId": "LCP 47", + "categoryTitle": "Algorithms", + "boundTopicId": 1016615, + "title": "入场安检", + "titleSlug": "oPs9Bm", + "content": "", + "translatedTitle": "入场安检", + "translatedContent": "「力扣挑战赛」 的入场仪式马上就要开始了,由于安保工作的需要,设置了可容纳人数总和为 `M` 的 `N` 个安检室,`capacities[i]` 记录第 `i` 个安检室可容纳人数。安检室拥有两种类型:\n- 先进先出:在安检室中的所有观众中,最早进入安检室的观众最先离开\n- 后进先出:在安检室中的所有观众中,最晚进入安检室的观众最先离开\n\n![c24754f1a5ff56989340ba5004dc5eda.gif](https://pic.leetcode-cn.com/1628843202-cdFPSt-c24754f1a5ff56989340ba5004dc5eda.gif)\n\n\n\n恰好 `M+1` 位入场的观众(编号从 0 开始)需要排队**依次**入场安检, 入场安检的规则如下:\n- 观众需要先进入编号 `0` 的安检室\n- 当观众将进入编号 `i` 的安检室时(`0 <= i < N`),\n - 若安检室未到达可容纳人数上限,该观众可直接进入;\n - 若安检室已到达可容纳人数上限,在该观众进入安检室之前需根据当前安检室类型选择一位观众离开后才能进入;\n- 当观众离开编号 `i` 的安检室时 (`0 <= i < N-1`),将进入编号 `i+1` 的安检室接受安检。\n\n若可以任意设定每个安检室的类型,请问有多少种设定安检室类型的方案可以使得编号 `k` 的观众第一个通过最后一个安检室入场。\n\n\n**注意:** \n- 观众不可主动离开安检室,只有当安检室容纳人数达到上限,且又有新观众需要进入时,才可根据安检室的类型选择一位观众离开;\n- 由于方案数可能过大,请将答案对 `1000000007` 取模后返回。\n\n\n**示例 1:**\n> 输入:`capacities = [2,2,3], k = 2`\n>\n> 输出:`2`\n> 解释:\n> 存在两种设定的 `2` 种方案:\n> - 方案 1:将编号为 `0` 、`1` 的实验室设置为 **后进先出** 的类型,编号为 `2` 的实验室设置为 **先进先出** 的类型;\n> - 方案 2:将编号为 `0` 、`1` 的实验室设置为 **先进先出** 的类型,编号为 `2` 的实验室设置为 **后进先出** 的类型。\n>\n> 以下是方案 1 的示意图:\n>![c60e38199a225ad62f13b954872edf9b.gif](https://pic.leetcode-cn.com/1628841618-bFKsnt-c60e38199a225ad62f13b954872edf9b.gif)\n\n\n\n**示例 2:**\n> 输入:`capacities = [3,3], k = 3`\n>\n> 输出:`0`\n\n**示例 3:**\n> 输入:`capacities = [4,3,2,2], k = 6`\n>\n> 输出:`2`\n\n**提示:**\n+ `1 <= capacities.length <= 200`\n+ `1 <= capacities[i] <= 200`\n+ `0 <= k <= sum(capacities)`\n", + "isPaidOnly": false, + "difficulty": "Hard", + "likes": 8, + "dislikes": 0, + "isLiked": null, + "similarQuestions": "[]", + "contributors": [ + { + "username": "LeetCode", + "profileUrl": "/u/leetcode", + "avatarUrl": "https://assets.leetcode-cn.com/aliyun-lc-upload/uploaded_files/2021/03/73c9f099-abbe-4d94-853f-f8abffd459cd/leetcode.png", + "__typename": "ContributorNode" + } + ], + "langToValidPlayground": "{\"cpp\": true, \"java\": true, \"python\": true, \"python3\": true, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"ruby\": false, \"bash\": false, \"swift\": false, \"golang\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"kotlin\": false, \"rust\": false, \"php\": false, \"typescript\": false, \"racket\": false, \"erlang\": false, \"elixir\": false}", + "topicTags": [ + { + "name": "Array", + "slug": "array", + "translatedName": "数组", + "__typename": "TopicTagNode" + }, + { + "name": "Dynamic Programming", + "slug": "dynamic-programming", + "translatedName": "动态规划", + "__typename": "TopicTagNode" + } + ], + "companyTagStats": null, + "codeSnippets": [ + { + "lang": "C++", + "langSlug": "cpp", + "code": "class Solution {\npublic:\n int securityCheck(vector& capacities, int k) {\n\n }\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Java", + "langSlug": "java", + "code": "class Solution {\n public int securityCheck(int[] capacities, int k) {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Python", + "langSlug": "python", + "code": "class Solution(object):\n def securityCheck(self, capacities, k):\n \"\"\"\n :type capacities: List[int]\n :type k: int\n :rtype: int\n \"\"\"", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Python3", + "langSlug": "python3", + "code": "class Solution:\n def securityCheck(self, capacities: List[int], k: int) -> int:", + "__typename": "CodeSnippetNode" + }, + { + "lang": "C", + "langSlug": "c", + "code": "\n\nint securityCheck(int* capacities, int capacitiesSize, int k){\n\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "C#", + "langSlug": "csharp", + "code": "public class Solution {\n public int SecurityCheck(int[] capacities, int k) {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "JavaScript", + "langSlug": "javascript", + "code": "/**\n * @param {number[]} capacities\n * @param {number} k\n * @return {number}\n */\nvar securityCheck = function(capacities, k) {\n\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Ruby", + "langSlug": "ruby", + "code": "# @param {Integer[]} capacities\n# @param {Integer} k\n# @return {Integer}\ndef security_check(capacities, k)\n\nend", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Swift", + "langSlug": "swift", + "code": "class Solution {\n func securityCheck(_ capacities: [Int], _ k: Int) -> Int {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Go", + "langSlug": "golang", + "code": "func securityCheck(capacities []int, k int) int {\n\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Scala", + "langSlug": "scala", + "code": "object Solution {\n def securityCheck(capacities: Array[Int], k: Int): Int = {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Kotlin", + "langSlug": "kotlin", + "code": "class Solution {\n fun securityCheck(capacities: IntArray, k: Int): Int {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Rust", + "langSlug": "rust", + "code": "impl Solution {\n pub fn security_check(capacities: Vec, k: i32) -> i32 {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "PHP", + "langSlug": "php", + "code": "class Solution {\n\n /**\n * @param Integer[] $capacities\n * @param Integer $k\n * @return Integer\n */\n function securityCheck($capacities, $k) {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "TypeScript", + "langSlug": "typescript", + "code": "function securityCheck(capacities: number[], k: number): number {\n\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Racket", + "langSlug": "racket", + "code": "(define/contract (security-check capacities k)\n (-> (listof exact-integer?) exact-integer? exact-integer?)\n\n )", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Erlang", + "langSlug": "erlang", + "code": "-spec security_check(Capacities :: [integer()], K :: integer()) -> integer().\nsecurity_check(Capacities, K) ->\n .", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Elixir", + "langSlug": "elixir", + "code": "defmodule Solution do\n @spec security_check(capacities :: [integer], k :: integer) :: integer\n def security_check(capacities, k) do\n\n end\nend", + "__typename": "CodeSnippetNode" + } + ], + "stats": "{\"totalAccepted\": \"1K\", \"totalSubmission\": \"2.7K\", \"totalAcceptedRaw\": 1037, \"totalSubmissionRaw\": 2684, \"acRate\": \"38.6%\"}", + "hints": [], + "solution": null, + "status": null, + "sampleTestCase": "[2,2,3]\n2", + "metaData": "{\"name\": \"securityCheck\", \"params\": [{\"name\": \"capacities\", \"type\": \"integer[]\"}, {\"name\": \"k\", \"type\": \"integer\"}], \"return\": {\"type\": \"integer\"}}", + "judgerAvailable": true, + "judgeType": "large", + "mysqlSchemas": [], + "enableRunCode": true, + "envInfo": "{\"cpp\":[\"C++\",\"

\\u7248\\u672c\\uff1aclang 11<\\/code> \\u91c7\\u7528\\u6700\\u65b0C++ 17\\u6807\\u51c6\\u3002<\\/p>\\r\\n\\r\\n

\\u7f16\\u8bd1\\u65f6\\uff0c\\u5c06\\u4f1a\\u91c7\\u7528-O2<\\/code>\\u7ea7\\u4f18\\u5316\\u3002AddressSanitizer<\\/a> \\u4e5f\\u88ab\\u5f00\\u542f\\u6765\\u68c0\\u6d4bout-of-bounds<\\/code>\\u548cuse-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 17<\\/code>\\u3002\\u53ef\\u4ee5\\u4f7f\\u7528Java 8\\u7684\\u7279\\u6027\\u4f8b\\u5982\\uff0clambda expressions \\u548c stream API\\u3002<\\/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.12<\\/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 \\u5c06\\u57282020\\u5e74\\u540e\\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 8.2<\\/code>\\uff0c\\u91c7\\u7528GNU99\\u6807\\u51c6\\u3002<\\/p>\\r\\n\\r\\n

\\u7f16\\u8bd1\\u65f6\\uff0c\\u5c06\\u4f1a\\u91c7\\u7528-O1<\\/code>\\u7ea7\\u4f18\\u5316\\u3002 AddressSanitizer<\\/a>\\u4e5f\\u88ab\\u5f00\\u542f\\u6765\\u68c0\\u6d4bout-of-bounds<\\/code>\\u548cuse-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# 10<\\/a> \\u8fd0\\u884c\\u5728 .NET 6 \\u4e0a<\\/p>\\r\\n\\r\\n

\\u60a8\\u7684\\u4ee3\\u7801\\u5728\\u7f16\\u8bd1\\u65f6\\u9ed8\\u8ba4\\u5f00\\u542f\\u4e86debug\\u6807\\u8bb0(\\/debug:pdbonly<\\/code>)\\u3002<\\/p>\"],\"javascript\":[\"JavaScript\",\"

\\u7248\\u672c\\uff1aNode.js 16.13.2<\\/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<\\/a> \\u548c datastructures-js\\/queue<\\/a>\\u3002<\\/p>\"],\"ruby\":[\"Ruby\",\"

\\u4f7f\\u7528Ruby 3.1<\\/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 5.5.2<\\/code><\\/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.17<\\/code><\\/p>\\r\\n\\r\\n

\\u652f\\u6301 https:\\/\\/godoc.org\\/github.com\\/emirpasic\\/gods<\\/a> \\u7b2c\\u4e09\\u65b9\\u5e93\\u3002<\\/p>\"],\"python3\":[\"Python3\",\"

\\u7248\\u672c\\uff1aPython 3.10<\\/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 2.13<\\/code><\\/p>\"],\"kotlin\":[\"Kotlin\",\"

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

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

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

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

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

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

Compile Options: --alwaysStrict --strictBindCallApply --strictFunctionTypes --target ES2020<\\/p>\"],\"racket\":[\"Racket\",\"

Racket CS<\\/a> v8.3<\\/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 24.2\"],\"elixir\":[\"Elixir\",\"Elixir 1.13.0 with Erlang\\/OTP 24.2\"]}", + "book": null, + "isSubscribed": false, + "isDailyQuestion": false, + "dailyRecordStatus": null, + "editorType": "MARKDOWN", + "ugcQuestionId": null, + "style": "LEETCODE", + "exampleTestcases": "[2,2,3]\n2\n[3,3]\n3\n[4,3,2,2]\n6", + "__typename": "QuestionNode" + } + } +} \ No newline at end of file diff --git a/算法题(国内版)/originData/sZ59z6.json b/算法题(国内版)/originData/sZ59z6.json new file mode 100644 index 00000000..f3626b60 --- /dev/null +++ b/算法题(国内版)/originData/sZ59z6.json @@ -0,0 +1,193 @@ +{ + "data": { + "question": { + "questionId": "1000362", + "questionFrontendId": "LCP 44", + "categoryTitle": "Algorithms", + "boundTopicId": 1016618, + "title": "开幕式焰火", + "titleSlug": "sZ59z6", + "content": "", + "translatedTitle": "开幕式焰火", + "translatedContent": "「力扣挑战赛」开幕式开始了,空中绽放了一颗二叉树形的巨型焰火。\n给定一棵二叉树 `root` 代表焰火,节点值表示巨型焰火这一位置的颜色种类。请帮小扣计算巨型焰火有多少种不同的颜色。\n\n\n**示例 1:**\n>输入:`root = [1,3,2,1,null,2]`\n>\n>输出:`3`\n>\n>解释:焰火中有 3 个不同的颜色,值分别为 1、2、3\n\n**示例 2:**\n>输入:`root = [3,3,3]`\n>\n>输出:`1`\n>\n>解释:焰火中仅出现 1 个颜色,值为 3\n\n**提示:**\n- `1 <= 节点个数 <= 1000`\n- `1 <= Node.val <= 1000`\n\n\n", + "isPaidOnly": false, + "difficulty": "Easy", + "likes": 14, + "dislikes": 0, + "isLiked": null, + "similarQuestions": "[]", + "contributors": [ + { + "username": "LeetCode", + "profileUrl": "/u/leetcode", + "avatarUrl": "https://assets.leetcode-cn.com/aliyun-lc-upload/uploaded_files/2021/03/73c9f099-abbe-4d94-853f-f8abffd459cd/leetcode.png", + "__typename": "ContributorNode" + } + ], + "langToValidPlayground": "{\"cpp\": true, \"java\": true, \"python\": true, \"python3\": true, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"ruby\": false, \"bash\": false, \"swift\": false, \"golang\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"kotlin\": false, \"rust\": false, \"php\": false, \"typescript\": false, \"racket\": false, \"erlang\": false, \"elixir\": false}", + "topicTags": [ + { + "name": "Tree", + "slug": "tree", + "translatedName": "树", + "__typename": "TopicTagNode" + }, + { + "name": "Depth-First Search", + "slug": "depth-first-search", + "translatedName": "深度优先搜索", + "__typename": "TopicTagNode" + }, + { + "name": "Breadth-First Search", + "slug": "breadth-first-search", + "translatedName": "广度优先搜索", + "__typename": "TopicTagNode" + }, + { + "name": "Hash Table", + "slug": "hash-table", + "translatedName": "哈希表", + "__typename": "TopicTagNode" + }, + { + "name": "Binary Tree", + "slug": "binary-tree", + "translatedName": "二叉树", + "__typename": "TopicTagNode" + } + ], + "companyTagStats": null, + "codeSnippets": [ + { + "lang": "C++", + "langSlug": "cpp", + "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode(int x) : val(x), left(NULL), right(NULL) {}\n * };\n */\nclass Solution {\npublic:\n int numColor(TreeNode* root) {\n\n }\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Java", + "langSlug": "java", + "code": "/**\n * Definition for a binary tree node.\n * public class TreeNode {\n * int val;\n * TreeNode left;\n * TreeNode right;\n * TreeNode(int x) { val = x; }\n * }\n */\nclass Solution {\n public int numColor(TreeNode root) {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Python", + "langSlug": "python", + "code": "# Definition for a binary tree node.\n# class TreeNode(object):\n# def __init__(self, x):\n# self.val = x\n# self.left = None\n# self.right = None\nclass Solution(object):\n def numColor(self, root):\n \"\"\"\n :type root: TreeNode\n :rtype: int\n \"\"\"", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Python3", + "langSlug": "python3", + "code": "# Definition for a binary tree node.\n# class TreeNode:\n# def __init__(self, x):\n# self.val = x\n# self.left = None\n# self.right = None\nclass Solution:\n def numColor(self, root: TreeNode) -> int:", + "__typename": "CodeSnippetNode" + }, + { + "lang": "C", + "langSlug": "c", + "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * struct TreeNode *left;\n * struct TreeNode *right;\n * };\n */\n\n\nint numColor(struct TreeNode* root){\n\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "C#", + "langSlug": "csharp", + "code": "/**\n * Definition for a binary tree node.\n * public class TreeNode {\n * public int val;\n * public TreeNode left;\n * public TreeNode right;\n * public TreeNode(int x) { val = x; }\n * }\n */\npublic class Solution {\n public int NumColor(TreeNode root) {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "JavaScript", + "langSlug": "javascript", + "code": "/**\n * Definition for a binary tree node.\n * function TreeNode(val) {\n * this.val = val;\n * this.left = this.right = null;\n * }\n */\n/**\n * @param {TreeNode} root\n * @return {number}\n */\nvar numColor = function(root) {\n\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Ruby", + "langSlug": "ruby", + "code": "# Definition for a binary tree node.\n# class TreeNode\n# attr_accessor :val, :left, :right\n# def initialize(val)\n# @val = val\n# @left, @right = nil, nil\n# end\n# end\n# @param {TreeNode} root\n# @return {Integer}\ndef num_color(root)\n\nend", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Swift", + "langSlug": "swift", + "code": "/**\n * Definition for a binary tree node.\n * public class TreeNode {\n * public var val: Int\n * public var left: TreeNode?\n * public var right: TreeNode?\n * public init(_ val: Int) {\n * self.val = val\n * self.left = nil\n * self.right = nil\n * }\n * }\n */\nclass Solution {\n func numColor(_ root: TreeNode?) -> Int {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Go", + "langSlug": "golang", + "code": "/**\n * Definition for a binary tree node.\n * type TreeNode struct {\n * Val int\n * Left *TreeNode\n * Right *TreeNode\n * }\n */\nfunc numColor(root *TreeNode) int {\n\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Scala", + "langSlug": "scala", + "code": "/**\n * Definition for a binary tree node.\n * class TreeNode(var _value: Int) {\n * var value: Int = _value\n * var left: TreeNode = null\n * var right: TreeNode = null\n * }\n */\nobject Solution {\n def numColor(root: TreeNode): Int = {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Kotlin", + "langSlug": "kotlin", + "code": "/**\n * Example:\n * var ti = TreeNode(5)\n * var v = ti.`val`\n * Definition for a binary tree node.\n * class TreeNode(var `val`: Int) {\n * var left: TreeNode? = null\n * var right: TreeNode? = null\n * }\n */\nclass Solution {\n fun numColor(root: TreeNode?): Int {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Rust", + "langSlug": "rust", + "code": "// Definition for a binary tree node.\n// #[derive(Debug, PartialEq, Eq)]\n// pub struct TreeNode {\n// pub val: i32,\n// pub left: Option>>,\n// pub right: Option>>,\n// }\n//\n// impl TreeNode {\n// #[inline]\n// pub fn new(val: i32) -> Self {\n// TreeNode {\n// val,\n// left: None,\n// right: None\n// }\n// }\n// }\nuse std::rc::Rc;\nuse std::cell::RefCell;\nimpl Solution {\n pub fn num_color(root: Option>>) -> i32 {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "PHP", + "langSlug": "php", + "code": "/**\n * Definition for a binary tree node.\n * class TreeNode {\n * public $val = null;\n * public $left = null;\n * public $right = null;\n * function __construct($value) { $this->val = $value; }\n * }\n */\nclass Solution {\n\n /**\n * @param TreeNode $root\n * @return Integer\n */\n function numColor($root) {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "TypeScript", + "langSlug": "typescript", + "code": "/**\n * Definition for a binary tree node.\n * class TreeNode {\n * val: number\n * left: TreeNode | null\n * right: TreeNode | null\n * constructor(val?: number, left?: TreeNode | null, right?: TreeNode | null) {\n * this.val = (val===undefined ? 0 : val)\n * this.left = (left===undefined ? null : left)\n * this.right = (right===undefined ? null : right)\n * }\n * }\n */\n\nfunction numColor(root: TreeNode | null): number {\n\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Racket", + "langSlug": "racket", + "code": "; Definition for a binary tree node.\n#|\n\n; val : integer?\n; left : (or/c tree-node? #f)\n; right : (or/c tree-node? #f)\n(struct tree-node\n (val left right) #:mutable #:transparent)\n\n; constructor\n(define (make-tree-node [val 0])\n (tree-node val #f #f))\n\n|#\n\n(define/contract (num-color root)\n (-> (or/c tree-node? #f) exact-integer?)\n\n )", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Erlang", + "langSlug": "erlang", + "code": "%% Definition for a binary tree node.\n%%\n%% -record(tree_node, {val = 0 :: integer(),\n%% left = null :: 'null' | #tree_node{},\n%% right = null :: 'null' | #tree_node{}}).\n\n-spec num_color(Root :: #tree_node{} | null) -> integer().\nnum_color(Root) ->\n .", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Elixir", + "langSlug": "elixir", + "code": "# Definition for a binary tree node.\n#\n# defmodule TreeNode do\n# @type t :: %__MODULE__{\n# val: integer,\n# left: TreeNode.t() | nil,\n# right: TreeNode.t() | nil\n# }\n# defstruct val: 0, left: nil, right: nil\n# end\n\ndefmodule Solution do\n @spec num_color(root :: TreeNode.t | nil) :: integer\n def num_color(root) do\n\n end\nend", + "__typename": "CodeSnippetNode" + } + ], + "stats": "{\"totalAccepted\": \"6.4K\", \"totalSubmission\": \"8.1K\", \"totalAcceptedRaw\": 6433, \"totalSubmissionRaw\": 8091, \"acRate\": \"79.5%\"}", + "hints": [], + "solution": null, + "status": null, + "sampleTestCase": "[1,3,2,1,null,2]", + "metaData": "{\"name\": \"numColor\", \"params\": [{\"name\": \"root\", \"type\": \"TreeNode\"}], \"return\": {\"type\": \"integer\"}}", + "judgerAvailable": true, + "judgeType": "large", + "mysqlSchemas": [], + "enableRunCode": true, + "envInfo": "{\"cpp\":[\"C++\",\"

\\u7248\\u672c\\uff1aclang 11<\\/code> \\u91c7\\u7528\\u6700\\u65b0C++ 17\\u6807\\u51c6\\u3002<\\/p>\\r\\n\\r\\n

\\u7f16\\u8bd1\\u65f6\\uff0c\\u5c06\\u4f1a\\u91c7\\u7528-O2<\\/code>\\u7ea7\\u4f18\\u5316\\u3002AddressSanitizer<\\/a> \\u4e5f\\u88ab\\u5f00\\u542f\\u6765\\u68c0\\u6d4bout-of-bounds<\\/code>\\u548cuse-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 17<\\/code>\\u3002\\u53ef\\u4ee5\\u4f7f\\u7528Java 8\\u7684\\u7279\\u6027\\u4f8b\\u5982\\uff0clambda expressions \\u548c stream API\\u3002<\\/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.12<\\/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 \\u5c06\\u57282020\\u5e74\\u540e\\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 8.2<\\/code>\\uff0c\\u91c7\\u7528GNU99\\u6807\\u51c6\\u3002<\\/p>\\r\\n\\r\\n

\\u7f16\\u8bd1\\u65f6\\uff0c\\u5c06\\u4f1a\\u91c7\\u7528-O1<\\/code>\\u7ea7\\u4f18\\u5316\\u3002 AddressSanitizer<\\/a>\\u4e5f\\u88ab\\u5f00\\u542f\\u6765\\u68c0\\u6d4bout-of-bounds<\\/code>\\u548cuse-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# 10<\\/a> \\u8fd0\\u884c\\u5728 .NET 6 \\u4e0a<\\/p>\\r\\n\\r\\n

\\u60a8\\u7684\\u4ee3\\u7801\\u5728\\u7f16\\u8bd1\\u65f6\\u9ed8\\u8ba4\\u5f00\\u542f\\u4e86debug\\u6807\\u8bb0(\\/debug:pdbonly<\\/code>)\\u3002<\\/p>\"],\"javascript\":[\"JavaScript\",\"

\\u7248\\u672c\\uff1aNode.js 16.13.2<\\/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<\\/a> \\u548c datastructures-js\\/queue<\\/a>\\u3002<\\/p>\"],\"ruby\":[\"Ruby\",\"

\\u4f7f\\u7528Ruby 3.1<\\/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 5.5.2<\\/code><\\/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.17<\\/code><\\/p>\\r\\n\\r\\n

\\u652f\\u6301 https:\\/\\/godoc.org\\/github.com\\/emirpasic\\/gods<\\/a> \\u7b2c\\u4e09\\u65b9\\u5e93\\u3002<\\/p>\"],\"python3\":[\"Python3\",\"

\\u7248\\u672c\\uff1aPython 3.10<\\/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 2.13<\\/code><\\/p>\"],\"kotlin\":[\"Kotlin\",\"

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

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

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

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

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

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

Compile Options: --alwaysStrict --strictBindCallApply --strictFunctionTypes --target ES2020<\\/p>\"],\"racket\":[\"Racket\",\"

Racket CS<\\/a> v8.3<\\/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 24.2\"],\"elixir\":[\"Elixir\",\"Elixir 1.13.0 with Erlang\\/OTP 24.2\"]}", + "book": null, + "isSubscribed": false, + "isDailyQuestion": false, + "dailyRecordStatus": null, + "editorType": "MARKDOWN", + "ugcQuestionId": null, + "style": "LEETCODE", + "exampleTestcases": "[1,3,2,1,null,2]\n[3,3,3]", + "__typename": "QuestionNode" + } + } +} \ No newline at end of file diff --git a/算法题(国内版)/originData/uOAnQW.json b/算法题(国内版)/originData/uOAnQW.json new file mode 100644 index 00000000..9f736227 --- /dev/null +++ b/算法题(国内版)/originData/uOAnQW.json @@ -0,0 +1,163 @@ +{ + "data": { + "question": { + "questionId": "1000368", + "questionFrontendId": "LCP 40", + "categoryTitle": "Algorithms", + "boundTopicId": 991679, + "title": "心算挑战", + "titleSlug": "uOAnQW", + "content": "", + "translatedTitle": "心算挑战", + "translatedContent": "「力扣挑战赛」心算项目的挑战比赛中,要求选手从 `N` 张卡牌中选出 `cnt` 张卡牌,若这 `cnt` 张卡牌数字总和为偶数,则选手成绩「有效」且得分为 `cnt` 张卡牌数字总和。\n给定数组 `cards` 和 `cnt`,其中 `cards[i]` 表示第 `i` 张卡牌上的数字。 请帮参赛选手计算最大的有效得分。若不存在获取有效得分的卡牌方案,则返回 0。\n\n**示例 1:**\n>输入:`cards = [1,2,8,9], cnt = 3`\n>\n>输出:`18`\n>\n>解释:选择数字为 1、8、9 的这三张卡牌,此时可获得最大的有效得分 1+8+9=18。\n\n**示例 2:**\n>输入:`cards = [3,3,1], cnt = 1`\n>\n>输出:`0`\n>\n>解释:不存在获取有效得分的卡牌方案。\n\n**提示:**\n- `1 <= cnt <= cards.length <= 10^5`\n- `1 <= cards[i] <= 1000`\n\n\n", + "isPaidOnly": false, + "difficulty": "Easy", + "likes": 27, + "dislikes": 0, + "isLiked": null, + "similarQuestions": "[]", + "contributors": [ + { + "username": "LeetCode", + "profileUrl": "/u/leetcode", + "avatarUrl": "https://assets.leetcode-cn.com/aliyun-lc-upload/uploaded_files/2021/03/73c9f099-abbe-4d94-853f-f8abffd459cd/leetcode.png", + "__typename": "ContributorNode" + } + ], + "langToValidPlayground": "{\"cpp\": true, \"java\": true, \"python\": true, \"python3\": true, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"ruby\": false, \"bash\": false, \"swift\": false, \"golang\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"kotlin\": false, \"rust\": false, \"php\": false, \"typescript\": false, \"racket\": false, \"erlang\": false, \"elixir\": false}", + "topicTags": [ + { + "name": "Greedy", + "slug": "greedy", + "translatedName": "贪心", + "__typename": "TopicTagNode" + }, + { + "name": "Array", + "slug": "array", + "translatedName": "数组", + "__typename": "TopicTagNode" + }, + { + "name": "Sorting", + "slug": "sorting", + "translatedName": "排序", + "__typename": "TopicTagNode" + } + ], + "companyTagStats": null, + "codeSnippets": [ + { + "lang": "C++", + "langSlug": "cpp", + "code": "class Solution {\npublic:\n int maxmiumScore(vector& cards, int cnt) {\n\n }\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Java", + "langSlug": "java", + "code": "class Solution {\n public int maxmiumScore(int[] cards, int cnt) {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Python", + "langSlug": "python", + "code": "class Solution(object):\n def maxmiumScore(self, cards, cnt):\n \"\"\"\n :type cards: List[int]\n :type cnt: int\n :rtype: int\n \"\"\"", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Python3", + "langSlug": "python3", + "code": "class Solution:\n def maxmiumScore(self, cards: List[int], cnt: int) -> int:", + "__typename": "CodeSnippetNode" + }, + { + "lang": "C", + "langSlug": "c", + "code": "\n\nint maxmiumScore(int* cards, int cardsSize, int cnt){\n\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "C#", + "langSlug": "csharp", + "code": "public class Solution {\n public int MaxmiumScore(int[] cards, int cnt) {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "JavaScript", + "langSlug": "javascript", + "code": "/**\n * @param {number[]} cards\n * @param {number} cnt\n * @return {number}\n */\nvar maxmiumScore = function(cards, cnt) {\n\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Ruby", + "langSlug": "ruby", + "code": "# @param {Integer[]} cards\n# @param {Integer} cnt\n# @return {Integer}\ndef maxmium_score(cards, cnt)\n\nend", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Swift", + "langSlug": "swift", + "code": "class Solution {\n func maxmiumScore(_ cards: [Int], _ cnt: Int) -> Int {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Go", + "langSlug": "golang", + "code": "func maxmiumScore(cards []int, cnt int) int {\n\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Scala", + "langSlug": "scala", + "code": "object Solution {\n def maxmiumScore(cards: Array[Int], cnt: Int): Int = {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Kotlin", + "langSlug": "kotlin", + "code": "class Solution {\n fun maxmiumScore(cards: IntArray, cnt: Int): Int {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Rust", + "langSlug": "rust", + "code": "impl Solution {\n pub fn maxmium_score(cards: Vec, cnt: i32) -> i32 {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "PHP", + "langSlug": "php", + "code": "class Solution {\n\n /**\n * @param Integer[] $cards\n * @param Integer $cnt\n * @return Integer\n */\n function maxmiumScore($cards, $cnt) {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "TypeScript", + "langSlug": "typescript", + "code": "function maxmiumScore(cards: number[], cnt: number): number {\n\n};", + "__typename": "CodeSnippetNode" + } + ], + "stats": "{\"totalAccepted\": \"4.4K\", \"totalSubmission\": \"16.4K\", \"totalAcceptedRaw\": 4431, \"totalSubmissionRaw\": 16442, \"acRate\": \"26.9%\"}", + "hints": [], + "solution": null, + "status": null, + "sampleTestCase": "[1,2,8,9]\n3", + "metaData": "{\"name\": \"maxmiumScore\", \"params\": [{\"name\": \"cards\", \"type\": \"integer[]\"}, {\"name\": \"cnt\", \"type\": \"integer\"}], \"return\": {\"type\": \"integer\"}}", + "judgerAvailable": true, + "judgeType": "large", + "mysqlSchemas": [], + "enableRunCode": true, + "envInfo": "{\"cpp\":[\"C++\",\"

\\u7248\\u672c\\uff1aclang 11<\\/code> \\u91c7\\u7528\\u6700\\u65b0C++ 17\\u6807\\u51c6\\u3002<\\/p>\\r\\n\\r\\n

\\u7f16\\u8bd1\\u65f6\\uff0c\\u5c06\\u4f1a\\u91c7\\u7528-O2<\\/code>\\u7ea7\\u4f18\\u5316\\u3002AddressSanitizer<\\/a> \\u4e5f\\u88ab\\u5f00\\u542f\\u6765\\u68c0\\u6d4bout-of-bounds<\\/code>\\u548cuse-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 17<\\/code>\\u3002\\u53ef\\u4ee5\\u4f7f\\u7528Java 8\\u7684\\u7279\\u6027\\u4f8b\\u5982\\uff0clambda expressions \\u548c stream API\\u3002<\\/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.12<\\/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 \\u5c06\\u57282020\\u5e74\\u540e\\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 8.2<\\/code>\\uff0c\\u91c7\\u7528GNU99\\u6807\\u51c6\\u3002<\\/p>\\r\\n\\r\\n

\\u7f16\\u8bd1\\u65f6\\uff0c\\u5c06\\u4f1a\\u91c7\\u7528-O1<\\/code>\\u7ea7\\u4f18\\u5316\\u3002 AddressSanitizer<\\/a>\\u4e5f\\u88ab\\u5f00\\u542f\\u6765\\u68c0\\u6d4bout-of-bounds<\\/code>\\u548cuse-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# 10<\\/a> \\u8fd0\\u884c\\u5728 .NET 6 \\u4e0a<\\/p>\\r\\n\\r\\n

\\u60a8\\u7684\\u4ee3\\u7801\\u5728\\u7f16\\u8bd1\\u65f6\\u9ed8\\u8ba4\\u5f00\\u542f\\u4e86debug\\u6807\\u8bb0(\\/debug:pdbonly<\\/code>)\\u3002<\\/p>\"],\"javascript\":[\"JavaScript\",\"

\\u7248\\u672c\\uff1aNode.js 16.13.2<\\/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<\\/a> \\u548c datastructures-js\\/queue<\\/a>\\u3002<\\/p>\"],\"ruby\":[\"Ruby\",\"

\\u4f7f\\u7528Ruby 3.1<\\/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 5.5.2<\\/code><\\/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.17<\\/code><\\/p>\\r\\n\\r\\n

\\u652f\\u6301 https:\\/\\/godoc.org\\/github.com\\/emirpasic\\/gods<\\/a> \\u7b2c\\u4e09\\u65b9\\u5e93\\u3002<\\/p>\"],\"python3\":[\"Python3\",\"

\\u7248\\u672c\\uff1aPython 3.10<\\/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 2.13<\\/code><\\/p>\"],\"kotlin\":[\"Kotlin\",\"

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

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

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

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

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

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

Compile Options: --alwaysStrict --strictBindCallApply --strictFunctionTypes --target ES2020<\\/p>\"]}", + "book": null, + "isSubscribed": false, + "isDailyQuestion": false, + "dailyRecordStatus": null, + "editorType": "MARKDOWN", + "ugcQuestionId": null, + "style": "LEETCODE", + "exampleTestcases": "[1,2,8,9]\n3\n[3,3,1]\n1", + "__typename": "QuestionNode" + } + } +} \ No newline at end of file diff --git a/算法题(国内版)/originData/uUsW3B.json b/算法题(国内版)/originData/uUsW3B.json new file mode 100644 index 00000000..f1e09657 --- /dev/null +++ b/算法题(国内版)/originData/uUsW3B.json @@ -0,0 +1,186 @@ +{ + "data": { + "question": { + "questionId": "1000344", + "questionFrontendId": "剑指 Offer II 080", + "categoryTitle": "LCOF2", + "boundTopicId": 910338, + "title": "含有 k 个元素的组合", + "titleSlug": "uUsW3B", + "content": "

English description is not available for the problem. Please switch to Chinese.

\n", + "translatedTitle": "含有 k 个元素的组合", + "translatedContent": "

给定两个整数 nk,返回 1 ... n 中所有可能的 k 个数的组合。

\n\n

 

\n\n

示例 1:

\n\n
\n输入: n = 4, k = 2\n输出:\n[\n  [2,4],\n  [3,4],\n  [2,3],\n  [1,2],\n  [1,3],\n  [1,4],\n]
\n\n

示例 2:

\n\n
\n输入: n = 1, k = 1\n输出: [[1]]
\n\n

 

\n\n

提示:

\n\n
    \n\t
  • 1 <= n <= 20
  • \n\t
  • 1 <= k <= n
  • \n
\n\n

 

\n\n

注意:本题与主站 77 题相同: https://leetcode-cn.com/problems/combinations/

\n", + "isPaidOnly": false, + "difficulty": "Medium", + "likes": 16, + "dislikes": 0, + "isLiked": null, + "similarQuestions": "[]", + "contributors": [ + { + "username": "LeetCode", + "profileUrl": "/u/leetcode", + "avatarUrl": "https://assets.leetcode-cn.com/aliyun-lc-upload/uploaded_files/2021/03/73c9f099-abbe-4d94-853f-f8abffd459cd/leetcode.png", + "__typename": "ContributorNode" + } + ], + "langToValidPlayground": "{\"cpp\": false, \"java\": true, \"python\": true, \"python3\": false, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"ruby\": false, \"bash\": false, \"swift\": false, \"golang\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"kotlin\": false, \"rust\": false, \"php\": false, \"typescript\": false, \"racket\": false, \"erlang\": false, \"elixir\": false}", + "topicTags": [ + { + "name": "Array", + "slug": "array", + "translatedName": "数组", + "__typename": "TopicTagNode" + }, + { + "name": "Backtracking", + "slug": "backtracking", + "translatedName": "回溯", + "__typename": "TopicTagNode" + } + ], + "companyTagStats": null, + "codeSnippets": [ + { + "lang": "C++", + "langSlug": "cpp", + "code": "class Solution {\npublic:\n vector> combine(int n, int k) {\n\n }\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Java", + "langSlug": "java", + "code": "class Solution {\n public List> combine(int n, int k) {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Python", + "langSlug": "python", + "code": "class Solution(object):\n def combine(self, n, k):\n \"\"\"\n :type n: int\n :type k: int\n :rtype: List[List[int]]\n \"\"\"", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Python3", + "langSlug": "python3", + "code": "class Solution:\n def combine(self, n: int, k: int) -> List[List[int]]:", + "__typename": "CodeSnippetNode" + }, + { + "lang": "C", + "langSlug": "c", + "code": "\n\n/**\n * Return an array of arrays of size *returnSize.\n * The sizes of the arrays are returned as *returnColumnSizes array.\n * Note: Both returned array and *columnSizes array must be malloced, assume caller calls free().\n */\nint** combine(int n, int k, int* returnSize, int** returnColumnSizes){\n\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "C#", + "langSlug": "csharp", + "code": "public class Solution {\n public IList> Combine(int n, int k) {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "JavaScript", + "langSlug": "javascript", + "code": "/**\n * @param {number} n\n * @param {number} k\n * @return {number[][]}\n */\nvar combine = function(n, k) {\n\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Ruby", + "langSlug": "ruby", + "code": "# @param {Integer} n\n# @param {Integer} k\n# @return {Integer[][]}\ndef combine(n, k)\n\nend", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Swift", + "langSlug": "swift", + "code": "class Solution {\n func combine(_ n: Int, _ k: Int) -> [[Int]] {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Go", + "langSlug": "golang", + "code": "func combine(n int, k int) [][]int {\n\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Scala", + "langSlug": "scala", + "code": "object Solution {\n def combine(n: Int, k: Int): List[List[Int]] = {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Kotlin", + "langSlug": "kotlin", + "code": "class Solution {\n fun combine(n: Int, k: Int): List> {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Rust", + "langSlug": "rust", + "code": "impl Solution {\n pub fn combine(n: i32, k: i32) -> Vec> {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "PHP", + "langSlug": "php", + "code": "class Solution {\n\n /**\n * @param Integer $n\n * @param Integer $k\n * @return Integer[][]\n */\n function combine($n, $k) {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "TypeScript", + "langSlug": "typescript", + "code": "function combine(n: number, k: number): number[][] {\n\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Racket", + "langSlug": "racket", + "code": "(define/contract (combine n k)\n (-> exact-integer? exact-integer? (listof (listof exact-integer?)))\n\n )", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Erlang", + "langSlug": "erlang", + "code": "-spec combine(N :: integer(), K :: integer()) -> [[integer()]].\ncombine(N, K) ->\n .", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Elixir", + "langSlug": "elixir", + "code": "defmodule Solution do\n @spec combine(n :: integer, k :: integer) :: [[integer]]\n def combine(n, k) do\n\n end\nend", + "__typename": "CodeSnippetNode" + } + ], + "stats": "{\"totalAccepted\": \"9K\", \"totalSubmission\": \"10.8K\", \"totalAcceptedRaw\": 9001, \"totalSubmissionRaw\": 10846, \"acRate\": \"83.0%\"}", + "hints": [], + "solution": null, + "status": null, + "sampleTestCase": "4\n2", + "metaData": "{\"name\": \"combine\", \"params\": [{\"name\": \"n\", \"type\": \"integer\"}, {\"name\": \"k\", \"type\": \"integer\"}], \"return\": {\"type\": \"integer[][]\"}}", + "judgerAvailable": true, + "judgeType": "large", + "mysqlSchemas": [], + "enableRunCode": true, + "envInfo": "{\"cpp\":[\"C++\",\"

\\u7248\\u672c\\uff1aclang 11<\\/code> \\u91c7\\u7528\\u6700\\u65b0C++ 17\\u6807\\u51c6\\u3002<\\/p>\\r\\n\\r\\n

\\u7f16\\u8bd1\\u65f6\\uff0c\\u5c06\\u4f1a\\u91c7\\u7528-O2<\\/code>\\u7ea7\\u4f18\\u5316\\u3002AddressSanitizer<\\/a> \\u4e5f\\u88ab\\u5f00\\u542f\\u6765\\u68c0\\u6d4bout-of-bounds<\\/code>\\u548cuse-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 17<\\/code>\\u3002\\u53ef\\u4ee5\\u4f7f\\u7528Java 8\\u7684\\u7279\\u6027\\u4f8b\\u5982\\uff0clambda expressions \\u548c stream API\\u3002<\\/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.12<\\/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 \\u5c06\\u57282020\\u5e74\\u540e\\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 8.2<\\/code>\\uff0c\\u91c7\\u7528GNU99\\u6807\\u51c6\\u3002<\\/p>\\r\\n\\r\\n

\\u7f16\\u8bd1\\u65f6\\uff0c\\u5c06\\u4f1a\\u91c7\\u7528-O1<\\/code>\\u7ea7\\u4f18\\u5316\\u3002 AddressSanitizer<\\/a>\\u4e5f\\u88ab\\u5f00\\u542f\\u6765\\u68c0\\u6d4bout-of-bounds<\\/code>\\u548cuse-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# 10<\\/a> \\u8fd0\\u884c\\u5728 .NET 6 \\u4e0a<\\/p>\\r\\n\\r\\n

\\u60a8\\u7684\\u4ee3\\u7801\\u5728\\u7f16\\u8bd1\\u65f6\\u9ed8\\u8ba4\\u5f00\\u542f\\u4e86debug\\u6807\\u8bb0(\\/debug:pdbonly<\\/code>)\\u3002<\\/p>\"],\"javascript\":[\"JavaScript\",\"

\\u7248\\u672c\\uff1aNode.js 16.13.2<\\/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<\\/a> \\u548c datastructures-js\\/queue<\\/a>\\u3002<\\/p>\"],\"ruby\":[\"Ruby\",\"

\\u4f7f\\u7528Ruby 3.1<\\/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 5.5.2<\\/code><\\/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.17<\\/code><\\/p>\\r\\n\\r\\n

\\u652f\\u6301 https:\\/\\/godoc.org\\/github.com\\/emirpasic\\/gods<\\/a> \\u7b2c\\u4e09\\u65b9\\u5e93\\u3002<\\/p>\"],\"python3\":[\"Python3\",\"

\\u7248\\u672c\\uff1aPython 3.10<\\/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 2.13<\\/code><\\/p>\"],\"kotlin\":[\"Kotlin\",\"

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

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

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

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

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

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

Compile Options: --alwaysStrict --strictBindCallApply --strictFunctionTypes --target ES2020<\\/p>\"],\"racket\":[\"Racket\",\"

Racket CS<\\/a> v8.3<\\/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 24.2\"],\"elixir\":[\"Elixir\",\"Elixir 1.13.0 with Erlang\\/OTP 24.2\"]}", + "book": { + "id": "8", + "bookName": "《剑指 Offer(专项突击版)》", + "pressName": "电子工业出版社", + "source": "《剑指 Offer(专项突击版)》独家授权", + "shortDescription": "通行全球的程序员经典面试秘籍", + "fullDescription": "本书精选国内外名企高频面试题并深度拓展,系统地总结了程序员面试中必备的数据结构与算法知识,并以面试者及面试官的双向视角剖析考点与解题思路,适合所有正在准备面试的程序员阅读。", + "bookImgUrl": "https://pic.leetcode-cn.com/1626752512-sWgHof-image.png", + "pressImgUrl": "https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2020/02/11/logo-01.png", + "productUrl": "", + "__typename": "CategoryInfoNode" + }, + "isSubscribed": false, + "isDailyQuestion": false, + "dailyRecordStatus": null, + "editorType": "CKEDITOR", + "ugcQuestionId": null, + "style": "LEETCODE", + "exampleTestcases": "", + "__typename": "QuestionNode" + } + } +} \ No newline at end of file diff --git a/算法题(国内版)/originData/vFjcfV.json b/算法题(国内版)/originData/vFjcfV.json new file mode 100644 index 00000000..92de77d9 --- /dev/null +++ b/算法题(国内版)/originData/vFjcfV.json @@ -0,0 +1,199 @@ +{ + "data": { + "question": { + "questionId": "1000371", + "questionFrontendId": "LCP 42", + "categoryTitle": "Algorithms", + "boundTopicId": 991682, + "title": "玩具套圈", + "titleSlug": "vFjcfV", + "content": "", + "translatedTitle": "玩具套圈", + "translatedContent": "「力扣挑战赛」场地外,小力组织了一个套玩具的游戏。所有的玩具摆在平地上,`toys[i]` 以 `[xi,yi,ri]` 的形式记录了第 `i` 个玩具的坐标 `(xi,yi)` 和半径 `ri`。小扣试玩了一下,他扔了若干个半径均为 `r` 的圈,`circles[j]` 记录了第 `j` 个圈的坐标 `(xj,yj)`。套圈的规则如下:\n- 若一个玩具被某个圈完整覆盖了(即玩具的任意部分均在圈内或者圈上),则该玩具被套中。\n- 若一个玩具被多个圈同时套中,最终仅计算为套中一个玩具\n\n请帮助小扣计算,他成功套中了多少玩具。\n\n**注意:**\n- 输入数据保证任意两个玩具的圆心不会重合,但玩具之间可能存在重叠。\n\n\n**示例 1:**\n\n> 输入:`toys = [[3,3,1],[3,2,1]], circles = [[4,3]], r = 2`\n>\n> 输出:`1`\n> \n> 解释: 如图所示,仅套中一个玩具\n![image.png](https://pic.leetcode-cn.com/1629194140-ydKiGF-image.png)\n\n\n**示例 2:**\n\n> 输入:`toys = [[1,3,2],[4,3,1],[7,1,2]], circles = [[1,0],[3,3]], r = 4`\n>\n> 输出:`2`\n> \n> 解释: 如图所示,套中两个玩具\n![image.png](https://pic.leetcode-cn.com/1629194157-RiOAuy-image.png){:width=\"400px\"}\n\n\n\n**提示:** \n- `1 <= toys.length <= 10^4`\n- `0 <= toys[i][0], toys[i][1] <= 10^9`\n- `1 <= circles.length <= 10^4`\n- `0 <= circles[i][0], circles[i][1] <= 10^9`\n- `1 <= toys[i][2], r <= 10`\n", + "isPaidOnly": false, + "difficulty": "Hard", + "likes": 11, + "dislikes": 0, + "isLiked": null, + "similarQuestions": "[]", + "contributors": [ + { + "username": "LeetCode", + "profileUrl": "/u/leetcode", + "avatarUrl": "https://assets.leetcode-cn.com/aliyun-lc-upload/uploaded_files/2021/03/73c9f099-abbe-4d94-853f-f8abffd459cd/leetcode.png", + "__typename": "ContributorNode" + } + ], + "langToValidPlayground": "{\"cpp\": false, \"java\": true, \"python\": true, \"python3\": false, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"ruby\": false, \"bash\": false, \"swift\": false, \"golang\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"kotlin\": false, \"rust\": false, \"php\": false, \"typescript\": false, \"racket\": false, \"erlang\": false, \"elixir\": false}", + "topicTags": [ + { + "name": "Geometry", + "slug": "geometry", + "translatedName": "几何", + "__typename": "TopicTagNode" + }, + { + "name": "Array", + "slug": "array", + "translatedName": "数组", + "__typename": "TopicTagNode" + }, + { + "name": "Hash Table", + "slug": "hash-table", + "translatedName": "哈希表", + "__typename": "TopicTagNode" + }, + { + "name": "Math", + "slug": "math", + "translatedName": "数学", + "__typename": "TopicTagNode" + }, + { + "name": "Binary Search", + "slug": "binary-search", + "translatedName": "二分查找", + "__typename": "TopicTagNode" + }, + { + "name": "Sorting", + "slug": "sorting", + "translatedName": "排序", + "__typename": "TopicTagNode" + } + ], + "companyTagStats": null, + "codeSnippets": [ + { + "lang": "C++", + "langSlug": "cpp", + "code": "class Solution {\npublic:\n int circleGame(vector>& toys, vector>& circles, int r) {\n\n }\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Java", + "langSlug": "java", + "code": "class Solution {\n public int circleGame(int[][] toys, int[][] circles, int r) {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Python", + "langSlug": "python", + "code": "class Solution(object):\n def circleGame(self, toys, circles, r):\n \"\"\"\n :type toys: List[List[int]]\n :type circles: List[List[int]]\n :type r: int\n :rtype: int\n \"\"\"", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Python3", + "langSlug": "python3", + "code": "class Solution:\n def circleGame(self, toys: List[List[int]], circles: List[List[int]], r: int) -> int:", + "__typename": "CodeSnippetNode" + }, + { + "lang": "C", + "langSlug": "c", + "code": "\n\nint circleGame(int** toys, int toysSize, int* toysColSize, int** circles, int circlesSize, int* circlesColSize, int r){\n\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "C#", + "langSlug": "csharp", + "code": "public class Solution {\n public int CircleGame(int[][] toys, int[][] circles, int r) {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "JavaScript", + "langSlug": "javascript", + "code": "/**\n * @param {number[][]} toys\n * @param {number[][]} circles\n * @param {number} r\n * @return {number}\n */\nvar circleGame = function(toys, circles, r) {\n\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Ruby", + "langSlug": "ruby", + "code": "# @param {Integer[][]} toys\n# @param {Integer[][]} circles\n# @param {Integer} r\n# @return {Integer}\ndef circle_game(toys, circles, r)\n\nend", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Swift", + "langSlug": "swift", + "code": "class Solution {\n func circleGame(_ toys: [[Int]], _ circles: [[Int]], _ r: Int) -> Int {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Go", + "langSlug": "golang", + "code": "func circleGame(toys [][]int, circles [][]int, r int) int {\n\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Scala", + "langSlug": "scala", + "code": "object Solution {\n def circleGame(toys: Array[Array[Int]], circles: Array[Array[Int]], r: Int): Int = {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Kotlin", + "langSlug": "kotlin", + "code": "class Solution {\n fun circleGame(toys: Array, circles: Array, r: Int): Int {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Rust", + "langSlug": "rust", + "code": "impl Solution {\n pub fn circle_game(toys: Vec>, circles: Vec>, r: i32) -> i32 {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "PHP", + "langSlug": "php", + "code": "class Solution {\n\n /**\n * @param Integer[][] $toys\n * @param Integer[][] $circles\n * @param Integer $r\n * @return Integer\n */\n function circleGame($toys, $circles, $r) {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "TypeScript", + "langSlug": "typescript", + "code": "function circleGame(toys: number[][], circles: number[][], r: number): number {\n\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Racket", + "langSlug": "racket", + "code": "(define/contract (circle-game toys circles r)\n (-> (listof (listof exact-integer?)) (listof (listof exact-integer?)) exact-integer? exact-integer?)\n\n )", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Erlang", + "langSlug": "erlang", + "code": "-spec circle_game(Toys :: [[integer()]], Circles :: [[integer()]], R :: integer()) -> integer().\ncircle_game(Toys, Circles, R) ->\n .", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Elixir", + "langSlug": "elixir", + "code": "defmodule Solution do\n @spec circle_game(toys :: [[integer]], circles :: [[integer]], r :: integer) :: integer\n def circle_game(toys, circles, r) do\n\n end\nend", + "__typename": "CodeSnippetNode" + } + ], + "stats": "{\"totalAccepted\": \"1.4K\", \"totalSubmission\": \"6.1K\", \"totalAcceptedRaw\": 1397, \"totalSubmissionRaw\": 6127, \"acRate\": \"22.8%\"}", + "hints": [], + "solution": null, + "status": null, + "sampleTestCase": "[[1,3,2],[4,3,1]]\n[[1,0],[3,3],[0,0],[3,4]]\n4", + "metaData": "{\"name\": \"circleGame\", \"params\": [{\"name\": \"toys\", \"type\": \"integer[][]\"}, {\"name\": \"circles\", \"type\": \"integer[][]\"}, {\"name\": \"r\", \"type\": \"integer\"}], \"return\": {\"type\": \"integer\"}}", + "judgerAvailable": true, + "judgeType": "large", + "mysqlSchemas": [], + "enableRunCode": true, + "envInfo": "{\"cpp\":[\"C++\",\"

\\u7248\\u672c\\uff1aclang 11<\\/code> \\u91c7\\u7528\\u6700\\u65b0C++ 17\\u6807\\u51c6\\u3002<\\/p>\\r\\n\\r\\n

\\u7f16\\u8bd1\\u65f6\\uff0c\\u5c06\\u4f1a\\u91c7\\u7528-O2<\\/code>\\u7ea7\\u4f18\\u5316\\u3002AddressSanitizer<\\/a> \\u4e5f\\u88ab\\u5f00\\u542f\\u6765\\u68c0\\u6d4bout-of-bounds<\\/code>\\u548cuse-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 17<\\/code>\\u3002\\u53ef\\u4ee5\\u4f7f\\u7528Java 8\\u7684\\u7279\\u6027\\u4f8b\\u5982\\uff0clambda expressions \\u548c stream API\\u3002<\\/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.12<\\/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 \\u5c06\\u57282020\\u5e74\\u540e\\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 8.2<\\/code>\\uff0c\\u91c7\\u7528GNU99\\u6807\\u51c6\\u3002<\\/p>\\r\\n\\r\\n

\\u7f16\\u8bd1\\u65f6\\uff0c\\u5c06\\u4f1a\\u91c7\\u7528-O1<\\/code>\\u7ea7\\u4f18\\u5316\\u3002 AddressSanitizer<\\/a>\\u4e5f\\u88ab\\u5f00\\u542f\\u6765\\u68c0\\u6d4bout-of-bounds<\\/code>\\u548cuse-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# 10<\\/a> \\u8fd0\\u884c\\u5728 .NET 6 \\u4e0a<\\/p>\\r\\n\\r\\n

\\u60a8\\u7684\\u4ee3\\u7801\\u5728\\u7f16\\u8bd1\\u65f6\\u9ed8\\u8ba4\\u5f00\\u542f\\u4e86debug\\u6807\\u8bb0(\\/debug:pdbonly<\\/code>)\\u3002<\\/p>\"],\"javascript\":[\"JavaScript\",\"

\\u7248\\u672c\\uff1aNode.js 16.13.2<\\/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<\\/a> \\u548c datastructures-js\\/queue<\\/a>\\u3002<\\/p>\"],\"ruby\":[\"Ruby\",\"

\\u4f7f\\u7528Ruby 3.1<\\/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 5.5.2<\\/code><\\/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.17<\\/code><\\/p>\\r\\n\\r\\n

\\u652f\\u6301 https:\\/\\/godoc.org\\/github.com\\/emirpasic\\/gods<\\/a> \\u7b2c\\u4e09\\u65b9\\u5e93\\u3002<\\/p>\"],\"python3\":[\"Python3\",\"

\\u7248\\u672c\\uff1aPython 3.10<\\/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 2.13<\\/code><\\/p>\"],\"kotlin\":[\"Kotlin\",\"

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

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

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

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

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

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

Compile Options: --alwaysStrict --strictBindCallApply --strictFunctionTypes --target ES2020<\\/p>\"],\"racket\":[\"Racket\",\"

Racket CS<\\/a> v8.3<\\/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 24.2\"],\"elixir\":[\"Elixir\",\"Elixir 1.13.0 with Erlang\\/OTP 24.2\"]}", + "book": null, + "isSubscribed": false, + "isDailyQuestion": false, + "dailyRecordStatus": null, + "editorType": "MARKDOWN", + "ugcQuestionId": null, + "style": "LEETCODE", + "exampleTestcases": "[[1,3,2],[4,3,1]]\n[[1,0],[3,3],[0,0],[3,4]]\n4\n[[3,4,5],[1,4,4],[4,4,1],[1,5,5]]\n[[4,1],[4,2]]\n6", + "__typename": "QuestionNode" + } + } +} \ No newline at end of file diff --git a/算法题(国内版)/originData/vvXgSW.json b/算法题(国内版)/originData/vvXgSW.json new file mode 100644 index 00000000..aeda4268 --- /dev/null +++ b/算法题(国内版)/originData/vvXgSW.json @@ -0,0 +1,198 @@ +{ + "data": { + "question": { + "questionId": "1000342", + "questionFrontendId": "剑指 Offer II 078", + "categoryTitle": "LCOF2", + "boundTopicId": 910336, + "title": "合并排序链表", + "titleSlug": "vvXgSW", + "content": "

English description is not available for the problem. Please switch to Chinese.

\n", + "translatedTitle": "合并排序链表", + "translatedContent": "

给定一个链表数组,每个链表都已经按升序排列。

\n\n

请将所有链表合并到一个升序链表中,返回合并后的链表。

\n\n

 

\n\n

示例 1:

\n\n
\n输入:lists = [[1,4,5],[1,3,4],[2,6]]\n输出:[1,1,2,3,4,4,5,6]\n解释:链表数组如下:\n[\n  1->4->5,\n  1->3->4,\n  2->6\n]\n将它们合并到一个有序链表中得到。\n1->1->2->3->4->4->5->6\n
\n\n

示例 2:

\n\n
\n输入:lists = []\n输出:[]\n
\n\n

示例 3:

\n\n
\n输入:lists = [[]]\n输出:[]\n
\n\n

 

\n\n

提示:

\n\n
    \n\t
  • k == lists.length
  • \n\t
  • 0 <= k <= 10^4
  • \n\t
  • 0 <= lists[i].length <= 500
  • \n\t
  • -10^4 <= lists[i][j] <= 10^4
  • \n\t
  • lists[i]升序 排列
  • \n\t
  • lists[i].length 的总和不超过 10^4
  • \n
\n\n

 

\n\n

注意:本题与主站 23 题相同: https://leetcode-cn.com/problems/merge-k-sorted-lists/

\n", + "isPaidOnly": false, + "difficulty": "Hard", + "likes": 33, + "dislikes": 0, + "isLiked": null, + "similarQuestions": "[]", + "contributors": [ + { + "username": "LeetCode", + "profileUrl": "/u/leetcode", + "avatarUrl": "https://assets.leetcode-cn.com/aliyun-lc-upload/uploaded_files/2021/03/73c9f099-abbe-4d94-853f-f8abffd459cd/leetcode.png", + "__typename": "ContributorNode" + } + ], + "langToValidPlayground": "{\"cpp\": false, \"java\": false, \"python\": true, \"python3\": false, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"ruby\": false, \"bash\": false, \"swift\": false, \"golang\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"kotlin\": false, \"rust\": false, \"php\": false, \"typescript\": false, \"racket\": false, \"erlang\": false, \"elixir\": false}", + "topicTags": [ + { + "name": "Linked List", + "slug": "linked-list", + "translatedName": "链表", + "__typename": "TopicTagNode" + }, + { + "name": "Divide and Conquer", + "slug": "divide-and-conquer", + "translatedName": "分治", + "__typename": "TopicTagNode" + }, + { + "name": "Heap (Priority Queue)", + "slug": "heap-priority-queue", + "translatedName": "堆(优先队列)", + "__typename": "TopicTagNode" + }, + { + "name": "Merge Sort", + "slug": "merge-sort", + "translatedName": "归并排序", + "__typename": "TopicTagNode" + } + ], + "companyTagStats": null, + "codeSnippets": [ + { + "lang": "C++", + "langSlug": "cpp", + "code": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\nclass Solution {\npublic:\n ListNode* mergeKLists(vector& lists) {\n\n }\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Java", + "langSlug": "java", + "code": "/**\n * Definition for singly-linked list.\n * public class ListNode {\n * int val;\n * ListNode next;\n * ListNode() {}\n * ListNode(int val) { this.val = val; }\n * ListNode(int val, ListNode next) { this.val = val; this.next = next; }\n * }\n */\nclass Solution {\n public ListNode mergeKLists(ListNode[] lists) {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Python", + "langSlug": "python", + "code": "# Definition for singly-linked list.\n# class ListNode(object):\n# def __init__(self, val=0, next=None):\n# self.val = val\n# self.next = next\nclass Solution(object):\n def mergeKLists(self, lists):\n \"\"\"\n :type lists: List[ListNode]\n :rtype: ListNode\n \"\"\"", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Python3", + "langSlug": "python3", + "code": "# Definition for singly-linked list.\n# class ListNode:\n# def __init__(self, val=0, next=None):\n# self.val = val\n# self.next = next\nclass Solution:\n def mergeKLists(self, lists: List[ListNode]) -> ListNode:", + "__typename": "CodeSnippetNode" + }, + { + "lang": "C", + "langSlug": "c", + "code": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * struct ListNode *next;\n * };\n */\n\n\nstruct ListNode* mergeKLists(struct ListNode** lists, int listsSize){\n\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "C#", + "langSlug": "csharp", + "code": "/**\n * Definition for singly-linked list.\n * public class ListNode {\n * public int val;\n * public ListNode next;\n * public ListNode(int val=0, ListNode next=null) {\n * this.val = val;\n * this.next = next;\n * }\n * }\n */\npublic class Solution {\n public ListNode MergeKLists(ListNode[] lists) {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "JavaScript", + "langSlug": "javascript", + "code": "/**\n * Definition for singly-linked list.\n * function ListNode(val, next) {\n * this.val = (val===undefined ? 0 : val)\n * this.next = (next===undefined ? null : next)\n * }\n */\n/**\n * @param {ListNode[]} lists\n * @return {ListNode}\n */\nvar mergeKLists = function(lists) {\n\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Ruby", + "langSlug": "ruby", + "code": "# Definition for singly-linked list.\n# class ListNode\n# attr_accessor :val, :next\n# def initialize(val = 0, _next = nil)\n# @val = val\n# @next = _next\n# end\n# end\n# @param {ListNode[]} lists\n# @return {ListNode}\ndef merge_k_lists(lists)\n\nend", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Swift", + "langSlug": "swift", + "code": "/**\n * Definition for singly-linked list.\n * public class ListNode {\n * public var val: Int\n * public var next: ListNode?\n * public init() { self.val = 0; self.next = nil; }\n * public init(_ val: Int) { self.val = val; self.next = nil; }\n * public init(_ val: Int, _ next: ListNode?) { self.val = val; self.next = next; }\n * }\n */\nclass Solution {\n func mergeKLists(_ lists: [ListNode?]) -> ListNode? {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Go", + "langSlug": "golang", + "code": "/**\n * Definition for singly-linked list.\n * type ListNode struct {\n * Val int\n * Next *ListNode\n * }\n */\nfunc mergeKLists(lists []*ListNode) *ListNode {\n\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Scala", + "langSlug": "scala", + "code": "/**\n * Definition for singly-linked list.\n * class ListNode(_x: Int = 0, _next: ListNode = null) {\n * var next: ListNode = _next\n * var x: Int = _x\n * }\n */\nobject Solution {\n def mergeKLists(lists: Array[ListNode]): ListNode = {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Kotlin", + "langSlug": "kotlin", + "code": "/**\n * Example:\n * var li = ListNode(5)\n * var v = li.`val`\n * Definition for singly-linked list.\n * class ListNode(var `val`: Int) {\n * var next: ListNode? = null\n * }\n */\nclass Solution {\n fun mergeKLists(lists: Array): ListNode? {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Rust", + "langSlug": "rust", + "code": "// Definition for singly-linked list.\n// #[derive(PartialEq, Eq, Clone, Debug)]\n// pub struct ListNode {\n// pub val: i32,\n// pub next: Option>\n// }\n//\n// impl ListNode {\n// #[inline]\n// fn new(val: i32) -> Self {\n// ListNode {\n// next: None,\n// val\n// }\n// }\n// }\nimpl Solution {\n pub fn merge_k_lists(lists: Vec>>) -> Option> {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "PHP", + "langSlug": "php", + "code": "/**\n * Definition for a singly-linked list.\n * class ListNode {\n * public $val = 0;\n * public $next = null;\n * function __construct($val = 0, $next = null) {\n * $this->val = $val;\n * $this->next = $next;\n * }\n * }\n */\nclass Solution {\n\n /**\n * @param ListNode[] $lists\n * @return ListNode\n */\n function mergeKLists($lists) {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "TypeScript", + "langSlug": "typescript", + "code": "/**\n * Definition for singly-linked list.\n * class ListNode {\n * val: number\n * next: ListNode | null\n * constructor(val?: number, next?: ListNode | null) {\n * this.val = (val===undefined ? 0 : val)\n * this.next = (next===undefined ? null : next)\n * }\n * }\n */\n\nfunction mergeKLists(lists: Array): ListNode | null {\n\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Racket", + "langSlug": "racket", + "code": "; Definition for singly-linked list:\n#|\n\n; val : integer?\n; next : (or/c list-node? #f)\n(struct list-node\n (val next) #:mutable #:transparent)\n\n; constructor\n(define (make-list-node [val 0])\n (list-node val #f))\n\n|#\n\n(define/contract (merge-k-lists lists)\n (-> (listof (or/c list-node? #f)) (or/c list-node? #f))\n\n )", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Erlang", + "langSlug": "erlang", + "code": "%% Definition for singly-linked list.\n%%\n%% -record(list_node, {val = 0 :: integer(),\n%% next = null :: 'null' | #list_node{}}).\n\n-spec merge_k_lists(Lists :: [#list_node{} | null]) -> #list_node{} | null.\nmerge_k_lists(Lists) ->\n .", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Elixir", + "langSlug": "elixir", + "code": "# Definition for singly-linked list.\n#\n# defmodule ListNode do\n# @type t :: %__MODULE__{\n# val: integer,\n# next: ListNode.t() | nil\n# }\n# defstruct val: 0, next: nil\n# end\n\ndefmodule Solution do\n @spec merge_k_lists(lists :: [ListNode.t | nil]) :: ListNode.t | nil\n def merge_k_lists(lists) do\n\n end\nend", + "__typename": "CodeSnippetNode" + } + ], + "stats": "{\"totalAccepted\": \"9.8K\", \"totalSubmission\": \"15.4K\", \"totalAcceptedRaw\": 9850, \"totalSubmissionRaw\": 15380, \"acRate\": \"64.0%\"}", + "hints": [], + "solution": null, + "status": null, + "sampleTestCase": "[[1,4,5],[1,3,4],[2,6]]", + "metaData": "{\"name\": \"mergeKLists\", \"params\": [{\"name\": \"lists\", \"type\": \"ListNode[]\"}], \"return\": {\"type\": \"ListNode\"}}", + "judgerAvailable": true, + "judgeType": "large", + "mysqlSchemas": [], + "enableRunCode": true, + "envInfo": "{\"cpp\":[\"C++\",\"

\\u7248\\u672c\\uff1aclang 11<\\/code> \\u91c7\\u7528\\u6700\\u65b0C++ 17\\u6807\\u51c6\\u3002<\\/p>\\r\\n\\r\\n

\\u7f16\\u8bd1\\u65f6\\uff0c\\u5c06\\u4f1a\\u91c7\\u7528-O2<\\/code>\\u7ea7\\u4f18\\u5316\\u3002AddressSanitizer<\\/a> \\u4e5f\\u88ab\\u5f00\\u542f\\u6765\\u68c0\\u6d4bout-of-bounds<\\/code>\\u548cuse-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 17<\\/code>\\u3002\\u53ef\\u4ee5\\u4f7f\\u7528Java 8\\u7684\\u7279\\u6027\\u4f8b\\u5982\\uff0clambda expressions \\u548c stream API\\u3002<\\/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.12<\\/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 \\u5c06\\u57282020\\u5e74\\u540e\\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 8.2<\\/code>\\uff0c\\u91c7\\u7528GNU99\\u6807\\u51c6\\u3002<\\/p>\\r\\n\\r\\n

\\u7f16\\u8bd1\\u65f6\\uff0c\\u5c06\\u4f1a\\u91c7\\u7528-O1<\\/code>\\u7ea7\\u4f18\\u5316\\u3002 AddressSanitizer<\\/a>\\u4e5f\\u88ab\\u5f00\\u542f\\u6765\\u68c0\\u6d4bout-of-bounds<\\/code>\\u548cuse-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# 10<\\/a> \\u8fd0\\u884c\\u5728 .NET 6 \\u4e0a<\\/p>\\r\\n\\r\\n

\\u60a8\\u7684\\u4ee3\\u7801\\u5728\\u7f16\\u8bd1\\u65f6\\u9ed8\\u8ba4\\u5f00\\u542f\\u4e86debug\\u6807\\u8bb0(\\/debug:pdbonly<\\/code>)\\u3002<\\/p>\"],\"javascript\":[\"JavaScript\",\"

\\u7248\\u672c\\uff1aNode.js 16.13.2<\\/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<\\/a> \\u548c datastructures-js\\/queue<\\/a>\\u3002<\\/p>\"],\"ruby\":[\"Ruby\",\"

\\u4f7f\\u7528Ruby 3.1<\\/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 5.5.2<\\/code><\\/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.17<\\/code><\\/p>\\r\\n\\r\\n

\\u652f\\u6301 https:\\/\\/godoc.org\\/github.com\\/emirpasic\\/gods<\\/a> \\u7b2c\\u4e09\\u65b9\\u5e93\\u3002<\\/p>\"],\"python3\":[\"Python3\",\"

\\u7248\\u672c\\uff1aPython 3.10<\\/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 2.13<\\/code><\\/p>\"],\"kotlin\":[\"Kotlin\",\"

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

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

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

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

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

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

Compile Options: --alwaysStrict --strictBindCallApply --strictFunctionTypes --target ES2020<\\/p>\"],\"racket\":[\"Racket\",\"

Racket CS<\\/a> v8.3<\\/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 24.2\"],\"elixir\":[\"Elixir\",\"Elixir 1.13.0 with Erlang\\/OTP 24.2\"]}", + "book": { + "id": "8", + "bookName": "《剑指 Offer(专项突击版)》", + "pressName": "电子工业出版社", + "source": "《剑指 Offer(专项突击版)》独家授权", + "shortDescription": "通行全球的程序员经典面试秘籍", + "fullDescription": "本书精选国内外名企高频面试题并深度拓展,系统地总结了程序员面试中必备的数据结构与算法知识,并以面试者及面试官的双向视角剖析考点与解题思路,适合所有正在准备面试的程序员阅读。", + "bookImgUrl": "https://pic.leetcode-cn.com/1626752512-sWgHof-image.png", + "pressImgUrl": "https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2020/02/11/logo-01.png", + "productUrl": "", + "__typename": "CategoryInfoNode" + }, + "isSubscribed": false, + "isDailyQuestion": false, + "dailyRecordStatus": null, + "editorType": "CKEDITOR", + "ugcQuestionId": null, + "style": "LEETCODE", + "exampleTestcases": "[[1,4,5],[1,3,4],[2,6]]\n[]\n[[]]", + "__typename": "QuestionNode" + } + } +} \ No newline at end of file diff --git a/算法题(国内版)/originData/xx4gT2.json b/算法题(国内版)/originData/xx4gT2.json new file mode 100644 index 00000000..f17e95f2 --- /dev/null +++ b/算法题(国内版)/originData/xx4gT2.json @@ -0,0 +1,204 @@ +{ + "data": { + "question": { + "questionId": "1000340", + "questionFrontendId": "剑指 Offer II 076", + "categoryTitle": "LCOF2", + "boundTopicId": 910334, + "title": "数组中的第 k 大的数字", + "titleSlug": "xx4gT2", + "content": "

English description is not available for the problem. Please switch to Chinese.

\n", + "translatedTitle": "数组中的第 k 大的数字", + "translatedContent": "

给定整数数组 nums 和整数 k,请返回数组中第 k 个最大的元素。

\n\n

请注意,你需要找的是数组排序后的第 k 个最大的元素,而不是第 k 个不同的元素。

\n\n

 

\n\n

示例 1:

\n\n
\n输入: [3,2,1,5,6,4] 和 k = 2\n输出: 5\n
\n\n

示例 2:

\n\n
\n输入: [3,2,3,1,2,4,5,5,6] 和 k = 4\n输出: 4
\n\n

 

\n\n

提示:

\n\n
    \n\t
  • 1 <= k <= nums.length <= 104
  • \n\t
  • -104 <= nums[i] <= 104
  • \n
\n\n

 

\n\n

注意:本题与主站 215 题相同: https://leetcode-cn.com/problems/kth-largest-element-in-an-array/

\n", + "isPaidOnly": false, + "difficulty": "Medium", + "likes": 28, + "dislikes": 0, + "isLiked": null, + "similarQuestions": "[]", + "contributors": [ + { + "username": "LeetCode", + "profileUrl": "/u/leetcode", + "avatarUrl": "https://assets.leetcode-cn.com/aliyun-lc-upload/uploaded_files/2021/03/73c9f099-abbe-4d94-853f-f8abffd459cd/leetcode.png", + "__typename": "ContributorNode" + } + ], + "langToValidPlayground": "{\"cpp\": true, \"java\": true, \"python\": true, \"python3\": true, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"ruby\": false, \"bash\": false, \"swift\": false, \"golang\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"kotlin\": false, \"rust\": false, \"php\": false, \"typescript\": false, \"racket\": false, \"erlang\": false, \"elixir\": false}", + "topicTags": [ + { + "name": "Array", + "slug": "array", + "translatedName": "数组", + "__typename": "TopicTagNode" + }, + { + "name": "Divide and Conquer", + "slug": "divide-and-conquer", + "translatedName": "分治", + "__typename": "TopicTagNode" + }, + { + "name": "Quickselect", + "slug": "quickselect", + "translatedName": "快速选择", + "__typename": "TopicTagNode" + }, + { + "name": "Sorting", + "slug": "sorting", + "translatedName": "排序", + "__typename": "TopicTagNode" + }, + { + "name": "Heap (Priority Queue)", + "slug": "heap-priority-queue", + "translatedName": "堆(优先队列)", + "__typename": "TopicTagNode" + } + ], + "companyTagStats": null, + "codeSnippets": [ + { + "lang": "C++", + "langSlug": "cpp", + "code": "class Solution {\npublic:\n int findKthLargest(vector& nums, int k) {\n\n }\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Java", + "langSlug": "java", + "code": "class Solution {\n public int findKthLargest(int[] nums, int k) {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Python", + "langSlug": "python", + "code": "class Solution(object):\n def findKthLargest(self, nums, k):\n \"\"\"\n :type nums: List[int]\n :type k: int\n :rtype: int\n \"\"\"", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Python3", + "langSlug": "python3", + "code": "class Solution:\n def findKthLargest(self, nums: List[int], k: int) -> int:", + "__typename": "CodeSnippetNode" + }, + { + "lang": "C", + "langSlug": "c", + "code": "\n\nint findKthLargest(int* nums, int numsSize, int k){\n\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "C#", + "langSlug": "csharp", + "code": "public class Solution {\n public int FindKthLargest(int[] nums, int k) {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "JavaScript", + "langSlug": "javascript", + "code": "/**\n * @param {number[]} nums\n * @param {number} k\n * @return {number}\n */\nvar findKthLargest = function(nums, k) {\n\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Ruby", + "langSlug": "ruby", + "code": "# @param {Integer[]} nums\n# @param {Integer} k\n# @return {Integer}\ndef find_kth_largest(nums, k)\n\nend", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Swift", + "langSlug": "swift", + "code": "class Solution {\n func findKthLargest(_ nums: [Int], _ k: Int) -> Int {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Go", + "langSlug": "golang", + "code": "func findKthLargest(nums []int, k int) int {\n\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Scala", + "langSlug": "scala", + "code": "object Solution {\n def findKthLargest(nums: Array[Int], k: Int): Int = {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Kotlin", + "langSlug": "kotlin", + "code": "class Solution {\n fun findKthLargest(nums: IntArray, k: Int): Int {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Rust", + "langSlug": "rust", + "code": "impl Solution {\n pub fn find_kth_largest(nums: Vec, k: i32) -> i32 {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "PHP", + "langSlug": "php", + "code": "class Solution {\n\n /**\n * @param Integer[] $nums\n * @param Integer $k\n * @return Integer\n */\n function findKthLargest($nums, $k) {\n\n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "TypeScript", + "langSlug": "typescript", + "code": "function findKthLargest(nums: number[], k: number): number {\n\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Racket", + "langSlug": "racket", + "code": "(define/contract (find-kth-largest nums k)\n (-> (listof exact-integer?) exact-integer? exact-integer?)\n\n )", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Erlang", + "langSlug": "erlang", + "code": "-spec find_kth_largest(Nums :: [integer()], K :: integer()) -> integer().\nfind_kth_largest(Nums, K) ->\n .", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Elixir", + "langSlug": "elixir", + "code": "defmodule Solution do\n @spec find_kth_largest(nums :: [integer], k :: integer) :: integer\n def find_kth_largest(nums, k) do\n\n end\nend", + "__typename": "CodeSnippetNode" + } + ], + "stats": "{\"totalAccepted\": \"14.7K\", \"totalSubmission\": \"21.5K\", \"totalAcceptedRaw\": 14650, \"totalSubmissionRaw\": 21528, \"acRate\": \"68.1%\"}", + "hints": [], + "solution": null, + "status": null, + "sampleTestCase": "[3,2,1,5,6,4]\n2", + "metaData": "{\"name\": \"findKthLargest\", \"params\": [{\"name\": \"nums\", \"type\": \"integer[]\"}, {\"name\": \"k\", \"type\": \"integer\"}], \"return\": {\"type\": \"integer\"}}", + "judgerAvailable": true, + "judgeType": "large", + "mysqlSchemas": [], + "enableRunCode": true, + "envInfo": "{\"cpp\":[\"C++\",\"

\\u7248\\u672c\\uff1aclang 11<\\/code> \\u91c7\\u7528\\u6700\\u65b0C++ 17\\u6807\\u51c6\\u3002<\\/p>\\r\\n\\r\\n

\\u7f16\\u8bd1\\u65f6\\uff0c\\u5c06\\u4f1a\\u91c7\\u7528-O2<\\/code>\\u7ea7\\u4f18\\u5316\\u3002AddressSanitizer<\\/a> \\u4e5f\\u88ab\\u5f00\\u542f\\u6765\\u68c0\\u6d4bout-of-bounds<\\/code>\\u548cuse-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 17<\\/code>\\u3002\\u53ef\\u4ee5\\u4f7f\\u7528Java 8\\u7684\\u7279\\u6027\\u4f8b\\u5982\\uff0clambda expressions \\u548c stream API\\u3002<\\/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.12<\\/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 \\u5c06\\u57282020\\u5e74\\u540e\\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 8.2<\\/code>\\uff0c\\u91c7\\u7528GNU99\\u6807\\u51c6\\u3002<\\/p>\\r\\n\\r\\n

\\u7f16\\u8bd1\\u65f6\\uff0c\\u5c06\\u4f1a\\u91c7\\u7528-O1<\\/code>\\u7ea7\\u4f18\\u5316\\u3002 AddressSanitizer<\\/a>\\u4e5f\\u88ab\\u5f00\\u542f\\u6765\\u68c0\\u6d4bout-of-bounds<\\/code>\\u548cuse-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# 10<\\/a> \\u8fd0\\u884c\\u5728 .NET 6 \\u4e0a<\\/p>\\r\\n\\r\\n

\\u60a8\\u7684\\u4ee3\\u7801\\u5728\\u7f16\\u8bd1\\u65f6\\u9ed8\\u8ba4\\u5f00\\u542f\\u4e86debug\\u6807\\u8bb0(\\/debug:pdbonly<\\/code>)\\u3002<\\/p>\"],\"javascript\":[\"JavaScript\",\"

\\u7248\\u672c\\uff1aNode.js 16.13.2<\\/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<\\/a> \\u548c datastructures-js\\/queue<\\/a>\\u3002<\\/p>\"],\"ruby\":[\"Ruby\",\"

\\u4f7f\\u7528Ruby 3.1<\\/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 5.5.2<\\/code><\\/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.17<\\/code><\\/p>\\r\\n\\r\\n

\\u652f\\u6301 https:\\/\\/godoc.org\\/github.com\\/emirpasic\\/gods<\\/a> \\u7b2c\\u4e09\\u65b9\\u5e93\\u3002<\\/p>\"],\"python3\":[\"Python3\",\"

\\u7248\\u672c\\uff1aPython 3.10<\\/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 2.13<\\/code><\\/p>\"],\"kotlin\":[\"Kotlin\",\"

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

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

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

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

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

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

Compile Options: --alwaysStrict --strictBindCallApply --strictFunctionTypes --target ES2020<\\/p>\"],\"racket\":[\"Racket\",\"

Racket CS<\\/a> v8.3<\\/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 24.2\"],\"elixir\":[\"Elixir\",\"Elixir 1.13.0 with Erlang\\/OTP 24.2\"]}", + "book": { + "id": "8", + "bookName": "《剑指 Offer(专项突击版)》", + "pressName": "电子工业出版社", + "source": "《剑指 Offer(专项突击版)》独家授权", + "shortDescription": "通行全球的程序员经典面试秘籍", + "fullDescription": "本书精选国内外名企高频面试题并深度拓展,系统地总结了程序员面试中必备的数据结构与算法知识,并以面试者及面试官的双向视角剖析考点与解题思路,适合所有正在准备面试的程序员阅读。", + "bookImgUrl": "https://pic.leetcode-cn.com/1626752512-sWgHof-image.png", + "pressImgUrl": "https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2020/02/11/logo-01.png", + "productUrl": "", + "__typename": "CategoryInfoNode" + }, + "isSubscribed": false, + "isDailyQuestion": false, + "dailyRecordStatus": null, + "editorType": "CKEDITOR", + "ugcQuestionId": null, + "style": "LEETCODE", + "exampleTestcases": "", + "__typename": "QuestionNode" + } + } +} \ No newline at end of file diff --git a/算法题(国内版)/problem (Chinese)/入场安检 [oPs9Bm].md b/算法题(国内版)/problem (Chinese)/入场安检 [oPs9Bm].md new file mode 100644 index 00000000..18e46dc2 --- /dev/null +++ b/算法题(国内版)/problem (Chinese)/入场安检 [oPs9Bm].md @@ -0,0 +1,51 @@ +「力扣挑战赛」 的入场仪式马上就要开始了,由于安保工作的需要,设置了可容纳人数总和为 `M` 的 `N` 个安检室,`capacities[i]` 记录第 `i` 个安检室可容纳人数。安检室拥有两种类型: +- 先进先出:在安检室中的所有观众中,最早进入安检室的观众最先离开 +- 后进先出:在安检室中的所有观众中,最晚进入安检室的观众最先离开 + +![c24754f1a5ff56989340ba5004dc5eda.gif](https://pic.leetcode-cn.com/1628843202-cdFPSt-c24754f1a5ff56989340ba5004dc5eda.gif) + + + +恰好 `M+1` 位入场的观众(编号从 0 开始)需要排队**依次**入场安检, 入场安检的规则如下: +- 观众需要先进入编号 `0` 的安检室 +- 当观众将进入编号 `i` 的安检室时(`0 <= i < N`), + - 若安检室未到达可容纳人数上限,该观众可直接进入; + - 若安检室已到达可容纳人数上限,在该观众进入安检室之前需根据当前安检室类型选择一位观众离开后才能进入; +- 当观众离开编号 `i` 的安检室时 (`0 <= i < N-1`),将进入编号 `i+1` 的安检室接受安检。 + +若可以任意设定每个安检室的类型,请问有多少种设定安检室类型的方案可以使得编号 `k` 的观众第一个通过最后一个安检室入场。 + + +**注意:** +- 观众不可主动离开安检室,只有当安检室容纳人数达到上限,且又有新观众需要进入时,才可根据安检室的类型选择一位观众离开; +- 由于方案数可能过大,请将答案对 `1000000007` 取模后返回。 + + +**示例 1:** +> 输入:`capacities = [2,2,3], k = 2` +> +> 输出:`2` +> 解释: +> 存在两种设定的 `2` 种方案: +> - 方案 1:将编号为 `0` 、`1` 的实验室设置为 **后进先出** 的类型,编号为 `2` 的实验室设置为 **先进先出** 的类型; +> - 方案 2:将编号为 `0` 、`1` 的实验室设置为 **先进先出** 的类型,编号为 `2` 的实验室设置为 **后进先出** 的类型。 +> +> 以下是方案 1 的示意图: +>![c60e38199a225ad62f13b954872edf9b.gif](https://pic.leetcode-cn.com/1628841618-bFKsnt-c60e38199a225ad62f13b954872edf9b.gif) + + + +**示例 2:** +> 输入:`capacities = [3,3], k = 3` +> +> 输出:`0` + +**示例 3:** +> 输入:`capacities = [4,3,2,2], k = 6` +> +> 输出:`2` + +**提示:** ++ `1 <= capacities.length <= 200` ++ `1 <= capacities[i] <= 200` ++ `0 <= k <= sum(capacities)` diff --git a/算法题(国内版)/problem (Chinese)/十字路口的交通 [Y1VbOX].md b/算法题(国内版)/problem (Chinese)/十字路口的交通 [Y1VbOX].md new file mode 100644 index 00000000..624384d7 --- /dev/null +++ b/算法题(国内版)/problem (Chinese)/十字路口的交通 [Y1VbOX].md @@ -0,0 +1,46 @@ +前往「力扣挑战赛」场馆的道路上,有一个拥堵的十字路口,该十字路口由两条双向两车道的路交叉构成。由于信号灯故障,交警需要手动指挥拥堵车辆。假定路口没有新的来车且一辆车从一个车道驶入另一个车道所需的时间恰好为一秒钟,长度为 4 的一维字符串数组 `directions` 中按照 **东、南、西、北** 顺序记录了四个方向从最靠近路口到最远离路口的车辆计划开往的方向。其中: +- `"E"` 表示向东行驶; +- `"S"` 表示向南行驶; +- `"W"` 表示向西行驶; +- `"N"` 表示向北行驶。 + +交警每秒钟只能指挥各个车道距离路口最近的一辆车,且每次指挥需要满足如下规则: +- 同一秒钟内,一个方向的车道只允许驶出一辆车; +- 同一秒钟内,一个方向的车道只允许驶入一辆车; +- 同一秒钟内,车辆的行驶路线不可相交。 + +请返回最少需要几秒钟,该十字路口等候的车辆才能全部走完。 + +各个车道驶出的车辆可能的行驶路线如图所示: + + +![图片.png](https://pic.leetcode-cn.com/1630393755-gyPeMM-%E5%9B%BE%E7%89%87.png){:height="350px"} + +**注意:** +- 测试数据保证不会出现掉头行驶指令,即某一方向的行驶车辆计划开往的方向不会是当前车辆所在的车道的方向; +- 表示堵塞车辆行驶方向的字符串仅用大写字母 `"E"`,`"N"`,`"W"`,`"S"` 表示。 + +**示例 1:** +>输入:`directions = ["W","N","ES","W"]` +> +>输出:`2` +> +>解释: +>第 1 秒:东西方向排在最前的车先行,剩余车辆状态 `["","N","S","W"]`; +>第 2 秒:南、西、北方向的车行驶,路口无等待车辆; +>因此最少需要 2 秒,返回 2。 + +**示例 2:** +>输入:`directions = ["NS","WE","SE","EW"]` +> +>输出:`3` +> +>解释: +>第 1 秒:四个方向排在最前的车均可驶出; +>第 2 秒:东南方向的车驶出,剩余车辆状态 `["","","E","W"]`; +>第 3 秒:西北方向的车驶出。 + + +**提示:** +- `directions.length = 4` +- `0 <= directions[i].length <= 20` diff --git a/算法题(国内版)/problem (Chinese)/合并排序链表 [vvXgSW].html b/算法题(国内版)/problem (Chinese)/合并排序链表 [vvXgSW].html new file mode 100644 index 00000000..6b42e65c --- /dev/null +++ b/算法题(国内版)/problem (Chinese)/合并排序链表 [vvXgSW].html @@ -0,0 +1,51 @@ +

给定一个链表数组,每个链表都已经按升序排列。

+ +

请将所有链表合并到一个升序链表中,返回合并后的链表。

+ +

 

+ +

示例 1:

+ +
+输入:lists = [[1,4,5],[1,3,4],[2,6]]
+输出:[1,1,2,3,4,4,5,6]
+解释:链表数组如下:
+[
+  1->4->5,
+  1->3->4,
+  2->6
+]
+将它们合并到一个有序链表中得到。
+1->1->2->3->4->4->5->6
+
+ +

示例 2:

+ +
+输入:lists = []
+输出:[]
+
+ +

示例 3:

+ +
+输入:lists = [[]]
+输出:[]
+
+ +

 

+ +

提示:

+ +
    +
  • k == lists.length
  • +
  • 0 <= k <= 10^4
  • +
  • 0 <= lists[i].length <= 500
  • +
  • -10^4 <= lists[i][j] <= 10^4
  • +
  • lists[i]升序 排列
  • +
  • lists[i].length 的总和不超过 10^4
  • +
+ +

 

+ +

注意:本题与主站 23 题相同: https://leetcode-cn.com/problems/merge-k-sorted-lists/

diff --git a/算法题(国内版)/problem (Chinese)/含有 k 个元素的组合 [uUsW3B].html b/算法题(国内版)/problem (Chinese)/含有 k 个元素的组合 [uUsW3B].html new file mode 100644 index 00000000..7d22e1bf --- /dev/null +++ b/算法题(国内版)/problem (Chinese)/含有 k 个元素的组合 [uUsW3B].html @@ -0,0 +1,36 @@ +

给定两个整数 nk,返回 1 ... n 中所有可能的 k 个数的组合。

+ +

 

+ +

示例 1:

+ +
+输入: n = 4, k = 2
+输出:
+[
+  [2,4],
+  [3,4],
+  [2,3],
+  [1,2],
+  [1,3],
+  [1,4],
+]
+ +

示例 2:

+ +
+输入: n = 1, k = 1
+输出: [[1]]
+ +

 

+ +

提示:

+ +
    +
  • 1 <= n <= 20
  • +
  • 1 <= k <= n
  • +
+ +

 

+ +

注意:本题与主站 77 题相同: https://leetcode-cn.com/problems/combinations/

diff --git a/算法题(国内版)/problem (Chinese)/开幕式焰火 [sZ59z6].md b/算法题(国内版)/problem (Chinese)/开幕式焰火 [sZ59z6].md new file mode 100644 index 00000000..cb4916fb --- /dev/null +++ b/算法题(国内版)/problem (Chinese)/开幕式焰火 [sZ59z6].md @@ -0,0 +1,23 @@ +「力扣挑战赛」开幕式开始了,空中绽放了一颗二叉树形的巨型焰火。 +给定一棵二叉树 `root` 代表焰火,节点值表示巨型焰火这一位置的颜色种类。请帮小扣计算巨型焰火有多少种不同的颜色。 + + +**示例 1:** +>输入:`root = [1,3,2,1,null,2]` +> +>输出:`3` +> +>解释:焰火中有 3 个不同的颜色,值分别为 1、2、3 + +**示例 2:** +>输入:`root = [3,3,3]` +> +>输出:`1` +> +>解释:焰火中仅出现 1 个颜色,值为 3 + +**提示:** +- `1 <= 节点个数 <= 1000` +- `1 <= Node.val <= 1000` + + diff --git a/算法题(国内版)/problem (Chinese)/心算挑战 [uOAnQW].md b/算法题(国内版)/problem (Chinese)/心算挑战 [uOAnQW].md new file mode 100644 index 00000000..818a8d9e --- /dev/null +++ b/算法题(国内版)/problem (Chinese)/心算挑战 [uOAnQW].md @@ -0,0 +1,22 @@ +「力扣挑战赛」心算项目的挑战比赛中,要求选手从 `N` 张卡牌中选出 `cnt` 张卡牌,若这 `cnt` 张卡牌数字总和为偶数,则选手成绩「有效」且得分为 `cnt` 张卡牌数字总和。 +给定数组 `cards` 和 `cnt`,其中 `cards[i]` 表示第 `i` 张卡牌上的数字。 请帮参赛选手计算最大的有效得分。若不存在获取有效得分的卡牌方案,则返回 0。 + +**示例 1:** +>输入:`cards = [1,2,8,9], cnt = 3` +> +>输出:`18` +> +>解释:选择数字为 1、8、9 的这三张卡牌,此时可获得最大的有效得分 1+8+9=18。 + +**示例 2:** +>输入:`cards = [3,3,1], cnt = 1` +> +>输出:`0` +> +>解释:不存在获取有效得分的卡牌方案。 + +**提示:** +- `1 <= cnt <= cards.length <= 10^5` +- `1 <= cards[i] <= 1000` + + diff --git a/算法题(国内版)/problem (Chinese)/志愿者调配 [05ZEDJ].md b/算法题(国内版)/problem (Chinese)/志愿者调配 [05ZEDJ].md new file mode 100644 index 00000000..3983981a --- /dev/null +++ b/算法题(国内版)/problem (Chinese)/志愿者调配 [05ZEDJ].md @@ -0,0 +1,44 @@ +「力扣挑战赛」有 `n` 个比赛场馆(场馆编号从 `0` 开始),场馆之间的通道分布情况记录于二维数组 `edges` 中,`edges[i]= [x, y]` 表示第 `i` 条通道连接场馆 `x` 和场馆 `y`(即两个场馆相邻)。初始每个场馆中都有一定人数的志愿者(不同场馆人数可能不同),后续 `m` 天每天均会根据赛事热度进行志愿者人数调配。调配方案分为如下三种: +1. 将编号为 `idx` 的场馆内的志愿者人数减半; +2. 将编号为 `idx` 的场馆相邻的场馆的志愿者人数都加上编号为 `idx` 的场馆的志愿者人数; +3. 将编号为 `idx` 的场馆相邻的场馆的志愿者人数都减去编号为 `idx` 的场馆的志愿者人数。 + +所有的调配信息记录于数组 `plans` 中,`plans[i] = [num,idx]` 表示第 `i` 天对编号 `idx` 的场馆执行了第 `num` 种调配方案。 +在比赛结束后对调配方案进行复盘时,不慎将第 `0` 个场馆的**最终**志愿者人数丢失,只保留了**初始**所有场馆的志愿者总人数 `totalNum` ,以及记录了第 `1 ~ n-1` 个场馆的**最终**志愿者人数的一维数组 `finalCnt`。请你根据现有的信息求出初始每个场馆的志愿者人数,并按场馆编号顺序返回志愿者人数列表。 + +**注意:** +- 测试数据保证当某场馆进行第一种调配时,该场馆的志愿者人数一定为偶数; +- 测试数据保证当某场馆进行第三种调配时,该场馆的相邻场馆志愿者人数不为负数; +- 测试数据保证比赛开始时每个场馆的志愿者人数都不超过 `10^9`; +- 测试数据保证给定的场馆间的道路分布情况中不会出现自环、重边的情况。 + + +**示例 1:** +>![image.png](https://pic.leetcode-cn.com/1630061228-gnZsOz-image.png) +> 输入: +>`finalCnt = [1,16], totalNum = 21, edges = [[0,1],[1,2]], plans = [[2,1],[1,0],[3,0]]` +> +> 输出:`[5,7,9]` +> +> 解释: +> ![image.png](https://pic.leetcode-cn.com/1630061300-WuVkeF-image.png){:height=200} + + +**示例 2 :** +> 输入: +>`finalCnt = [4,13,4,3,8], totalNum = 54, edges = [[0,3],[1,3],[4,3],[2,3],[2,5]], plans = [[1,1],[3,3],[2,5],[1,0]]` +> +> 输出:`[10,16,9,4,7,8]` + + + +**提示:** +- `2 <= n <= 5*10^4` +- `1 <= edges.length <= min((n * (n - 1)) / 2, 5*10^4)` +- `0 <= edges[i][0], edges[i][1] < n` +- `1 <= plans.length <= 10` +- `1 <= plans[i][0] <=3` +- `0 <= plans[i][1] < n` +- `finalCnt.length = n-1` +- `0 <= finalCnt[i] < 10^9` +- `0 <= totalNum < 5*10^13` diff --git a/算法题(国内版)/problem (Chinese)/所有子集 [TVdhkn].html b/算法题(国内版)/problem (Chinese)/所有子集 [TVdhkn].html new file mode 100644 index 00000000..b1c6678e --- /dev/null +++ b/算法题(国内版)/problem (Chinese)/所有子集 [TVdhkn].html @@ -0,0 +1,33 @@ +

给定一个整数数组 nums ,数组中的元素 互不相同 。返回该数组所有可能的子集(幂集)。

+ +

解集 不能 包含重复的子集。你可以按 任意顺序 返回解集。

+ +

 

+ +

示例 1:

+ +
+输入:nums = [1,2,3]
+输出:[[],[1],[2],[1,2],[3],[1,3],[2,3],[1,2,3]]
+
+ +

示例 2:

+ +
+输入:nums = [0]
+输出:[[],[0]]
+
+ +

 

+ +

提示:

+ +
    +
  • 1 <= nums.length <= 10
  • +
  • -10 <= nums[i] <= 10
  • +
  • nums 中的所有元素 互不相同
  • +
+ +

 

+ +

注意:本题与主站 78 题相同: https://leetcode-cn.com/problems/subsets/

diff --git a/算法题(国内版)/problem (Chinese)/数组中的第 k 大的数字 [xx4gT2].html b/算法题(国内版)/problem (Chinese)/数组中的第 k 大的数字 [xx4gT2].html new file mode 100644 index 00000000..11c052ba --- /dev/null +++ b/算法题(国内版)/problem (Chinese)/数组中的第 k 大的数字 [xx4gT2].html @@ -0,0 +1,31 @@ +

给定整数数组 nums 和整数 k,请返回数组中第 k 个最大的元素。

+ +

请注意,你需要找的是数组排序后的第 k 个最大的元素,而不是第 k 个不同的元素。

+ +

 

+ +

示例 1:

+ +
+输入: [3,2,1,5,6,4] 和 k = 2
+输出: 5
+
+ +

示例 2:

+ +
+输入: [3,2,3,1,2,4,5,5,6] 和 k = 4
+输出: 4
+ +

 

+ +

提示:

+ +
    +
  • 1 <= k <= nums.length <= 104
  • +
  • -104 <= nums[i] <= 104
  • +
+ +

 

+ +

注意:本题与主站 215 题相同: https://leetcode-cn.com/problems/kth-largest-element-in-an-array/

diff --git a/算法题(国内版)/problem (Chinese)/无人机方阵 [0jQkd0].md b/算法题(国内版)/problem (Chinese)/无人机方阵 [0jQkd0].md new file mode 100644 index 00000000..d9c6ca05 --- /dev/null +++ b/算法题(国内版)/problem (Chinese)/无人机方阵 [0jQkd0].md @@ -0,0 +1,45 @@ +在 「力扣挑战赛」 开幕式的压轴节目 「无人机方阵」中,每一架无人机展示一种灯光颜色。 无人机方阵通过两种操作进行颜色图案变换: +- 调整无人机的位置布局 +- 切换无人机展示的灯光颜色 + + +给定两个大小均为 `N*M` 的二维数组 `source` 和 `target` 表示无人机方阵表演的两种颜色图案,由于无人机切换灯光颜色的耗能很大,请返回从 `source` 到 `target` 最少需要多少架无人机切换灯光颜色。 + + +**注意:** 调整无人机的位置布局时无人机的位置可以随意变动。 + + +**示例 1:** +> 输入:`source = [[1,3],[5,4]], target = [[3,1],[6,5]]` +> +> 输出:`1` +> +> 解释: +> 最佳方案为 +将 `[0,1]` 处的无人机移动至 `[0,0]` 处; +将 `[0,0]` 处的无人机移动至 `[0,1]` 处; +将 `[1,0]` 处的无人机移动至 `[1,1]` 处; +将 `[1,1]` 处的无人机移动至 `[1,0]` 处,其灯光颜色切换为颜色编号为 `6` 的灯光; +因此从`source` 到 `target` 所需要的最少灯光切换次数为 1。 +>![8819ccdd664e91c78cde3bba3c701986.gif](https://pic.leetcode-cn.com/1628823765-uCDaux-8819ccdd664e91c78cde3bba3c701986.gif){:height=300px} + + + + + +**示例 2:** +> 输入:`source = [[1,2,3],[3,4,5]], target = [[1,3,5],[2,3,4]]` +> +> 输出:`0` +> 解释: +> 仅需调整无人机的位置布局,便可完成图案切换。因此不需要无人机切换颜色 + + +**提示:** +`n == source.length == target.length` +`m == source[i].length == target[i].length` +`1 <= n, m <=100` +`1 <= source[i][j], target[i][j] <=10^4` + + + diff --git a/算法题(国内版)/problem (Chinese)/无限棋局 [fsa7oZ].md b/算法题(国内版)/problem (Chinese)/无限棋局 [fsa7oZ].md new file mode 100644 index 00000000..3a980327 --- /dev/null +++ b/算法题(国内版)/problem (Chinese)/无限棋局 [fsa7oZ].md @@ -0,0 +1,35 @@ +小力正在通过残局练习来备战「力扣挑战赛」中的「五子棋」项目,他想请你能帮他预测当前残局的输赢情况。棋盘中的棋子分布信息记录于二维数组 `pieces` 中,其中 `pieces[i] = [x,y,color]` 表示第 `i` 枚棋子的横坐标为 `x`,纵坐标为 `y`,棋子颜色为 `color`(`0` 表示黑棋,`1` 表示白棋)。假如黑棋先行,并且黑棋和白棋都按最优策略落子,请你求出当前棋局在三步(按 **黑、白、黑** 的落子顺序)之内的输赢情况(三步之内先构成同行、列或对角线连续同颜色的至少 5 颗即为获胜): +- 黑棋胜, 请返回 `"Black"` +- 白棋胜, 请返回 `"White"` +- 仍无胜者, 请返回 `"None"` + +**注意:** +- 和传统的五子棋项目不同,「力扣挑战赛」中的「五子棋」项目 **不存在边界限制**,即可在 **任意位置** 落子; +- 黑棋和白棋均按 3 步内的输赢情况进行最优策略的选择 +- 测试数据保证所给棋局目前无胜者; +- 测试数据保证不会存在坐标一样的棋子。 + +**示例 1:** +> 输入: +> `pieces = [[0,0,1],[1,1,1],[2,2,0]]` +> +> 输出:`"None"` +> +> 解释:无论黑、白棋以何种方式落子,三步以内都不会产生胜者。 + +**示例 2:** +> 输入: +> `pieces = [[1,2,1],[1,4,1],[1,5,1],[2,1,0],[2,3,0],[2,4,0],[3,2,1],[3,4,0],[4,2,1],[5,2,1]]` +> +> 输出:`"Black"` +> +> 解释:三步之内黑棋必胜,以下是一种可能的落子情况: +>![902b87df29998b1c181146c8fdb3a4b6.gif](https://pic.leetcode-cn.com/1629800639-KabOfY-902b87df29998b1c181146c8fdb3a4b6.gif){:width="300px"} + + + +**提示:** +- `0 <= pieces.length <= 1000` +- `pieces[i].length = 3` +- `-10^9 <= pieces[i][0], pieces[i][1] <=10^9` +- `0 <= pieces[i][2] <=1` diff --git a/算法题(国内版)/problem (Chinese)/玩具套圈 [vFjcfV].md b/算法题(国内版)/problem (Chinese)/玩具套圈 [vFjcfV].md new file mode 100644 index 00000000..e61f3d99 --- /dev/null +++ b/算法题(国内版)/problem (Chinese)/玩具套圈 [vFjcfV].md @@ -0,0 +1,37 @@ +「力扣挑战赛」场地外,小力组织了一个套玩具的游戏。所有的玩具摆在平地上,`toys[i]` 以 `[xi,yi,ri]` 的形式记录了第 `i` 个玩具的坐标 `(xi,yi)` 和半径 `ri`。小扣试玩了一下,他扔了若干个半径均为 `r` 的圈,`circles[j]` 记录了第 `j` 个圈的坐标 `(xj,yj)`。套圈的规则如下: +- 若一个玩具被某个圈完整覆盖了(即玩具的任意部分均在圈内或者圈上),则该玩具被套中。 +- 若一个玩具被多个圈同时套中,最终仅计算为套中一个玩具 + +请帮助小扣计算,他成功套中了多少玩具。 + +**注意:** +- 输入数据保证任意两个玩具的圆心不会重合,但玩具之间可能存在重叠。 + + +**示例 1:** + +> 输入:`toys = [[3,3,1],[3,2,1]], circles = [[4,3]], r = 2` +> +> 输出:`1` +> +> 解释: 如图所示,仅套中一个玩具 +![image.png](https://pic.leetcode-cn.com/1629194140-ydKiGF-image.png) + + +**示例 2:** + +> 输入:`toys = [[1,3,2],[4,3,1],[7,1,2]], circles = [[1,0],[3,3]], r = 4` +> +> 输出:`2` +> +> 解释: 如图所示,套中两个玩具 +![image.png](https://pic.leetcode-cn.com/1629194157-RiOAuy-image.png){:width="400px"} + + + +**提示:** +- `1 <= toys.length <= 10^4` +- `0 <= toys[i][0], toys[i][1] <= 10^9` +- `1 <= circles.length <= 10^4` +- `0 <= circles[i][0], circles[i][1] <= 10^9` +- `1 <= toys[i][2], r <= 10` diff --git a/算法题(国内版)/problem (Chinese)/环形闯关游戏 [K8GULz].md b/算法题(国内版)/problem (Chinese)/环形闯关游戏 [K8GULz].md new file mode 100644 index 00000000..61b4fb17 --- /dev/null +++ b/算法题(国内版)/problem (Chinese)/环形闯关游戏 [K8GULz].md @@ -0,0 +1,48 @@ +「力扣挑战赛」中有一个由 `N` 个关卡组成的**环形**闯关游戏,关卡编号为 `0`~`N-1`,编号 `0` 的关卡和编号 `N-1` 的关卡相邻。每个关卡均有积分要求,`challenge[i]` 表示挑战编号 `i` 的关卡最少需要拥有的积分。 +![图片.png](https://pic.leetcode-cn.com/1630392170-ucncVS-%E5%9B%BE%E7%89%87.png){:width="240px"} + + +小扣想要挑战关卡,闯关的具体规则如下: + +- 初始小扣可以指定其中一个关卡为「开启」状态,其余关卡将处于「未开启」状态。 +- 小扣可以挑战处于「开启」状态且**满足最少积分要求**的关卡,若小扣挑战该关卡前积分为 `score`,挑战结束后,积分将增长为 `score|challenge[i]`(即位运算中的 `"OR"` 运算) +- 在挑战某个关卡后,该关卡两侧相邻的关卡将会开启(若之前未开启) + +请帮助小扣进行计算,初始最少需要多少积分,可以挑战 **环形闯关游戏** 的所有关卡。 + +**示例1:** + +> 输入:`challenge = [5,4,6,2,7]` +> +> 输出:`4` +> +> 解释: 初始选择编号 3 的关卡开启,积分为 4 +>挑战编号 3 的关卡,积分变为 $4 | 2 = 6$,开启 2、4 处的关卡 +>挑战编号 2 的关卡,积分变为 $6 | 6 = 6$,开启 1 处的关卡 +>挑战编号 1 的关卡,积分变为 $6 | 4 = 6$,开启 0 处的关卡 +>挑战编号 0 的关卡,积分变为 $6 | 5 = 7$ +>挑战编号 4 的关卡,顺利完成全部的关卡 + + +**示例2:** + +> 输入:`challenge = [12,7,11,3,9]` +> +> 输出:`8` +> +> 解释: 初始选择编号 3 的关卡开启,积分为 8 +>挑战编号 3 的关卡,积分变为 $8 | 3 = 11$,开启 2、4 处的关卡 +>挑战编号 2 的关卡,积分变为 $11 | 11 = 11$,开启 1 处的关卡 +>挑战编号 4 的关卡,积分变为 $11 | 9 = 11$,开启 0 处的关卡 +>挑战编号 1 的关卡,积分变为 $11 | 7 = 15$ +>挑战编号 0 的关卡,顺利完成全部的关卡 + +**示例3:** + +> 输入:`challenge = [1,1,1]` +> +> 输出:`1` + +**提示:** +- `1 <= challenge.length <= 5*10^4` +- `1 <= challenge[i] <= 10^18` \ No newline at end of file diff --git a/算法题(国内版)/problem (Chinese)/省份数量 [bLyHh0].html b/算法题(国内版)/problem (Chinese)/省份数量 [bLyHh0].html new file mode 100644 index 00000000..7180c65b --- /dev/null +++ b/算法题(国内版)/problem (Chinese)/省份数量 [bLyHh0].html @@ -0,0 +1,42 @@ +
+

n 个城市,其中一些彼此相连,另一些没有相连。如果城市 a 与城市 b 直接相连,且城市 b 与城市 c 直接相连,那么城市 a 与城市 c 间接相连。

+ +

省份 是一组直接或间接相连的城市,组内不含其他没有相连的城市。

+ +

给你一个 n x n 的矩阵 isConnected ,其中 isConnected[i][j] = 1 表示第 i 个城市和第 j 个城市直接相连,而 isConnected[i][j] = 0 表示二者不直接相连。

+ +

返回矩阵中 省份 的数量。

+ +

 

+ +

示例 1:

+ +
+输入:isConnected = [[1,1,0],[1,1,0],[0,0,1]]
+输出:2
+
+ +

示例 2:

+ +
+输入:isConnected = [[1,0,0],[0,1,0],[0,0,1]]
+输出:3
+
+ +

 

+ +

提示:

+ +
    +
  • 1 <= n <= 200
  • +
  • n == isConnected.length
  • +
  • n == isConnected[i].length
  • +
  • isConnected[i][j]10
  • +
  • isConnected[i][i] == 1
  • +
  • isConnected[i][j] == isConnected[j][i]
  • +
+
+ +

 

+ +

注意:本题与主站 547 题相同: https://leetcode-cn.com/problems/number-of-provinces/

diff --git a/算法题(国内版)/problem (Chinese)/自行车炫技赛场 [kplEvH].md b/算法题(国内版)/problem (Chinese)/自行车炫技赛场 [kplEvH].md new file mode 100644 index 00000000..b062d612 --- /dev/null +++ b/算法题(国内版)/problem (Chinese)/自行车炫技赛场 [kplEvH].md @@ -0,0 +1,33 @@ +「力扣挑战赛」中 `N*M` 大小的自行车炫技赛场的场地由一片连绵起伏的上下坡组成,场地的高度值记录于二维数组 `terrain` 中,场地的减速值记录于二维数组 `obstacle` 中。 +- 若选手骑着自行车从高度为 `h1` 且减速值为 `o1` 的位置到高度为 `h2` 且减速值为 `o2` 的相邻位置(上下左右四个方向),速度变化值为 `h1-h2-o2`(负值减速,正值增速)。 + +选手初始位于坐标 `position` 处且初始速度为 1,请问选手可以刚好到其他哪些位置时速度依旧为 1。请以二维数组形式返回这些位置。若有多个位置则按行坐标升序排列,若有多个位置行坐标相同则按列坐标升序排列。 + +**注意:** 骑行过程中速度不能为零或负值 + +**示例 1:** +> 输入:`position = [0,0], terrain = [[0,0],[0,0]], obstacle = [[0,0],[0,0]]` +> +> 输出:`[[0,1],[1,0],[1,1]]` +> +> 解释: +> 由于当前场地属于平地,根据上面的规则,选手从`[0,0]`的位置出发都能刚好在其他处的位置速度为 1。 + +**示例 2:** +> 输入:`position = [1,1], terrain = [[5,0],[0,6]], obstacle = [[0,6],[7,0]]` +> +> 输出:`[[0,1]]` +> +> 解释: +> 选手从 `[1,1]` 处的位置出发,到 `[0,1]` 处的位置时恰好速度为 1。 + + +**提示:** +- `n == terrain.length == obstacle.length` +- `m == terrain[i].length == obstacle[i].length` +- `1 <= n <= 100` +- `1 <= m <= 100` +- `0 <= terrain[i][j], obstacle[i][j] <= 100` +- `position.length == 2` +- `0 <= position[0] < n` +- `0 <= position[1] < m` \ No newline at end of file diff --git a/算法题(国内版)/problem (Chinese)/路径的数目 [2AoeFn].html b/算法题(国内版)/problem (Chinese)/路径的数目 [2AoeFn].html new file mode 100644 index 00000000..96ed02a8 --- /dev/null +++ b/算法题(国内版)/problem (Chinese)/路径的数目 [2AoeFn].html @@ -0,0 +1,53 @@ +

一个机器人位于一个 m x n 网格的左上角 (起始点在下图中标记为 “Start” )。

+ +

机器人每次只能向下或者向右移动一步。机器人试图达到网格的右下角(在下图中标记为 “Finish” )。

+ +

问总共有多少条不同的路径?

+ +

 

+ +

示例 1:

+ +

+ +
+输入:m = 3, n = 7
+输出:28
+ +

示例 2:

+ +
+输入:m = 3, n = 2
+输出:3
+解释:
+从左上角开始,总共有 3 条路径可以到达右下角。
+1. 向右 -> 向下 -> 向下
+2. 向下 -> 向下 -> 向右
+3. 向下 -> 向右 -> 向下
+
+ +

示例 3:

+ +
+输入:m = 7, n = 3
+输出:28
+
+ +

示例 4:

+ +
+输入:m = 3, n = 3
+输出:6
+ +

 

+ +

提示:

+ +
    +
  • 1 <= m, n <= 100
  • +
  • 题目数据保证答案小于等于 2 * 109
  • +
+ +

 

+ +

注意:本题与主站 62 题相同: https://leetcode-cn.com/problems/unique-paths/

diff --git a/算法题(国内版)/problem (Chinese)/链表排序 [7WHec2].html b/算法题(国内版)/problem (Chinese)/链表排序 [7WHec2].html new file mode 100644 index 00000000..0a481116 --- /dev/null +++ b/算法题(国内版)/problem (Chinese)/链表排序 [7WHec2].html @@ -0,0 +1,48 @@ +

给定链表的头结点 head ,请将其按 升序 排列并返回 排序后的链表

+ +
    +
+ +

 

+ +

示例 1:

+ +

+ +
+输入:head = [4,2,1,3]
+输出:[1,2,3,4]
+
+ +

示例 2:

+ +

+ +
+输入:head = [-1,5,3,4,0]
+输出:[-1,0,3,4,5]
+
+ +

示例 3:

+ +
+输入:head = []
+输出:[]
+
+ +

 

+ +

提示:

+ +
    +
  • 链表中节点的数目在范围 [0, 5 * 104] 内
  • +
  • -105 <= Node.val <= 105
  • +
+ +

 

+ +

进阶:你可以在 O(n log n) 时间复杂度和常数级空间复杂度下,对链表进行排序吗?

+ +

 

+ +

注意:本题与主站 148 题相同:https://leetcode-cn.com/problems/sort-list/

diff --git a/算法题(国内版)/problem (Chinese)/黑白翻转棋 [fHi6rV].md b/算法题(国内版)/problem (Chinese)/黑白翻转棋 [fHi6rV].md new file mode 100644 index 00000000..3c092885 --- /dev/null +++ b/算法题(国内版)/problem (Chinese)/黑白翻转棋 [fHi6rV].md @@ -0,0 +1,43 @@ +在 `n*m` 大小的棋盘中,有黑白两种棋子,黑棋记作字母 `"X"`, 白棋记作字母 `"O"`,空余位置记作 `"."`。当落下的棋子与其他相同颜色的棋子在行、列或对角线完全包围(中间不存在空白位置)另一种颜色的棋子,则可以翻转这些棋子的颜色。 + + + +![1.gif](https://pic.leetcode-cn.com/1630396029-eTgzpN-6da662e67368466a96d203f67bb6e793.gif){:height=170px}![2.gif](https://pic.leetcode-cn.com/1630396240-nMvdcc-8e4261afe9f60e05a4f740694b439b6b.gif){:height=170px}![3.gif](https://pic.leetcode-cn.com/1630396291-kEtzLL-6fcb682daeecb5c3f56eb88b23c81d33.gif){:height=170px} + +「力扣挑战赛」黑白翻转棋项目中,将提供给选手一个未形成可翻转棋子的棋盘残局,其状态记作 `chessboard`。若下一步可放置一枚黑棋,请问选手最多能翻转多少枚白棋。 + +**注意:** +- 若翻转白棋成黑棋后,棋盘上仍存在可以翻转的白棋,将可以 **继续** 翻转白棋 +- 输入数据保证初始棋盘状态无可以翻转的棋子且存在空余位置 + +**示例 1:** +> 输入:`chessboard = ["....X.","....X.","XOOO..","......","......"]` +> +> 输出:`3` +> +> 解释: +> 可以选择下在 `[2,4]` 处,能够翻转白方三枚棋子。 + +**示例 2:** +> 输入:`chessboard = [".X.",".O.","XO."]` +> +> 输出:`2` +> +> 解释: +> 可以选择下在 `[2,2]` 处,能够翻转白方两枚棋子。 +![2126c1d21b1b9a9924c639d449cc6e65.gif](https://pic.leetcode-cn.com/1626683255-OBtBud-2126c1d21b1b9a9924c639d449cc6e65.gif) + +**示例 3:** +> 输入:`chessboard = [".......",".......",".......","X......",".O.....","..O....","....OOX"]` +> +> 输出:`4` +> +> 解释: +> 可以选择下在 `[6,3]` 处,能够翻转白方四枚棋子。 +![803f2f04098b6174397d6c696f54d709.gif](https://pic.leetcode-cn.com/1630393770-Puyked-803f2f04098b6174397d6c696f54d709.gif) + + + +**提示:** +- `1 <= chessboard.length, chessboard[i].length <= 8` +- `chessboard[i]` 仅包含 `"."、"O"` 和 `"X"` \ No newline at end of file diff --git a/算法题(国内版)/problem (English)/合并排序链表(English) [vvXgSW].html b/算法题(国内版)/problem (English)/合并排序链表(English) [vvXgSW].html new file mode 100644 index 00000000..579f7fd7 --- /dev/null +++ b/算法题(国内版)/problem (English)/合并排序链表(English) [vvXgSW].html @@ -0,0 +1 @@ +

English description is not available for the problem. Please switch to Chinese.

diff --git a/算法题(国内版)/problem (English)/含有 k 个元素的组合(English) [uUsW3B].html b/算法题(国内版)/problem (English)/含有 k 个元素的组合(English) [uUsW3B].html new file mode 100644 index 00000000..579f7fd7 --- /dev/null +++ b/算法题(国内版)/problem (English)/含有 k 个元素的组合(English) [uUsW3B].html @@ -0,0 +1 @@ +

English description is not available for the problem. Please switch to Chinese.

diff --git a/算法题(国内版)/problem (English)/所有子集(English) [TVdhkn].html b/算法题(国内版)/problem (English)/所有子集(English) [TVdhkn].html new file mode 100644 index 00000000..579f7fd7 --- /dev/null +++ b/算法题(国内版)/problem (English)/所有子集(English) [TVdhkn].html @@ -0,0 +1 @@ +

English description is not available for the problem. Please switch to Chinese.

diff --git a/算法题(国内版)/problem (English)/数组中的第 k 大的数字(English) [xx4gT2].html b/算法题(国内版)/problem (English)/数组中的第 k 大的数字(English) [xx4gT2].html new file mode 100644 index 00000000..579f7fd7 --- /dev/null +++ b/算法题(国内版)/problem (English)/数组中的第 k 大的数字(English) [xx4gT2].html @@ -0,0 +1 @@ +

English description is not available for the problem. Please switch to Chinese.

diff --git a/算法题(国内版)/problem (English)/省份数量(English) [bLyHh0].html b/算法题(国内版)/problem (English)/省份数量(English) [bLyHh0].html new file mode 100644 index 00000000..579f7fd7 --- /dev/null +++ b/算法题(国内版)/problem (English)/省份数量(English) [bLyHh0].html @@ -0,0 +1 @@ +

English description is not available for the problem. Please switch to Chinese.

diff --git a/算法题(国内版)/problem (English)/路径的数目(English) [2AoeFn].html b/算法题(国内版)/problem (English)/路径的数目(English) [2AoeFn].html new file mode 100644 index 00000000..579f7fd7 --- /dev/null +++ b/算法题(国内版)/problem (English)/路径的数目(English) [2AoeFn].html @@ -0,0 +1 @@ +

English description is not available for the problem. Please switch to Chinese.

diff --git a/算法题(国内版)/problem (English)/链表排序(English) [7WHec2].html b/算法题(国内版)/problem (English)/链表排序(English) [7WHec2].html new file mode 100644 index 00000000..579f7fd7 --- /dev/null +++ b/算法题(国内版)/problem (English)/链表排序(English) [7WHec2].html @@ -0,0 +1 @@ +

English description is not available for the problem. Please switch to Chinese.