1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-05 15:31:43 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
2022-05-02 23:44:12 +08:00
parent 7ea03594b3
commit 2a71c78585
4790 changed files with 11696 additions and 10944 deletions

View File

@@ -12,7 +12,7 @@
"translatedContent": "<p>给定一个单词列表&nbsp;<code>words</code>&nbsp;和一个整数 <code>k</code> ,返回前&nbsp;<code>k</code><em>&nbsp;</em>个出现次数最多的单词。</p>\n\n<p>返回的答案应该按单词出现频率由高到低排序。如果不同的单词有相同出现频率, <strong>按字典顺序</strong> 排序。</p>\n\n<p>&nbsp;</p>\n\n<p><strong>示例 1</strong></p>\n\n<pre>\n<strong>输入:</strong> words = [\"i\", \"love\", \"leetcode\", \"i\", \"love\", \"coding\"], k = 2\n<strong>输出:</strong> [\"i\", \"love\"]\n<strong>解析:</strong> \"i\" 和 \"love\" 为出现次数最多的两个单词均为2次。\n 注意,按字母顺序 \"i\" 在 \"love\" 之前。\n</pre>\n\n<p><strong>示例 2</strong></p>\n\n<pre>\n<strong>输入:</strong> [\"the\", \"day\", \"is\", \"sunny\", \"the\", \"the\", \"the\", \"sunny\", \"is\", \"is\"], k = 4\n<strong>输出:</strong> [\"the\", \"is\", \"sunny\", \"day\"]\n<strong>解析:</strong> \"the\", \"is\", \"sunny\" 和 \"day\" 是出现次数最多的四个单词,\n 出现次数依次为 4, 3, 2 和 1 次。\n</pre>\n\n<p>&nbsp;</p>\n\n<p><strong>注意:</strong></p>\n\n<ul>\n\t<li><code>1 &lt;= words.length &lt;= 500</code></li>\n\t<li><code>1 &lt;= words[i] &lt;= 10</code></li>\n\t<li><code>words[i]</code>&nbsp;由小写英文字母组成。</li>\n\t<li><code>k</code> 的取值范围是&nbsp;<code>[1, <strong>不同</strong> words[i] 的数量]</code></li>\n</ul>\n\n<p>&nbsp;</p>\n\n<p><strong>进阶:</strong>尝试以&nbsp;<code>O(n log k)</code> 时间复杂度和&nbsp;<code>O(n)</code> 空间复杂度解决。</p>\n",
"isPaidOnly": false,
"difficulty": "Medium",
"likes": 439,
"likes": 447,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[{\"title\": \"Top K Frequent Elements\", \"titleSlug\": \"top-k-frequent-elements\", \"difficulty\": \"Medium\", \"translatedTitle\": \"\\u524d K \\u4e2a\\u9ad8\\u9891\\u5143\\u7d20\"}, {\"title\": \"K Closest Points to Origin\", \"titleSlug\": \"k-closest-points-to-origin\", \"difficulty\": \"Medium\", \"translatedTitle\": \"\\u6700\\u63a5\\u8fd1\\u539f\\u70b9\\u7684 K \\u4e2a\\u70b9\"}]",
@@ -173,11 +173,11 @@
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"77.6K\", \"totalSubmission\": \"136K\", \"totalAcceptedRaw\": 77623, \"totalSubmissionRaw\": 136034, \"acRate\": \"57.1%\"}",
"stats": "{\"totalAccepted\": \"79.9K\", \"totalSubmission\": \"140.2K\", \"totalAcceptedRaw\": 79874, \"totalSubmissionRaw\": 140208, \"acRate\": \"57.0%\"}",
"hints": [],
"solution": null,
"status": null,
"sampleTestCase": "[\"i\",\"love\",\"leetcode\",\"i\",\"love\",\"coding\"]\n2",
"sampleTestCase": "[\"i\", \"love\", \"leetcode\", \"i\", \"love\", \"coding\"]\n2",
"metaData": "{\r\n \"name\": \"topKFrequent\",\r\n \"params\": [\r\n {\r\n \"name\": \"words\",\r\n \"type\": \"string[]\"\r\n },\r\n {\r\n \"name\": \"k\",\r\n \"type\": \"integer\"\r\n }\r\n ],\r\n \"return\": {\r\n \"type\": \"list<string>\"\r\n }\r\n}\r\n",
"judgerAvailable": true,
"judgeType": "large",