mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-10-21 13:06:47 +08:00
update
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"translatedContent": "<p>数组中占比超过一半的元素称之为主要元素。给你一个<strong> 整数 </strong>数组,找出其中的主要元素。若没有,返回 <code>-1</code> 。请设计时间复杂度为 <code>O(N)</code> 、空间复杂度为 <code>O(1)</code> 的解决方案。</p>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n\n<pre>\n<strong>输入:</strong>[1,2,5,9,5,9,5,5,5]\n<strong>输出:</strong>5</pre>\n\n<p><strong>示例 2:</strong></p>\n\n<pre>\n<strong>输入:</strong>[3,2]\n<strong>输出:</strong>-1</pre>\n\n<p><strong>示例 3:</strong></p>\n\n<pre>\n<strong>输入:</strong>[2,2,1,1,1,2,2]\n<strong>输出:</strong>2</pre>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Easy",
|
||||
"likes": 197,
|
||||
"likes": 199,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
@@ -143,7 +143,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"70.6K\", \"totalSubmission\": \"124.2K\", \"totalAcceptedRaw\": 70625, \"totalSubmissionRaw\": 124234, \"acRate\": \"56.8%\"}",
|
||||
"stats": "{\"totalAccepted\": \"71.2K\", \"totalSubmission\": \"125.5K\", \"totalAcceptedRaw\": 71246, \"totalSubmissionRaw\": 125469, \"acRate\": \"56.8%\"}",
|
||||
"hints": [
|
||||
"从蛮力解法开始。你能检查一下每个值是否为主要元素吗?",
|
||||
"考虑蛮力解法。我们选择一个元素,然后通过计算匹配和非匹配元素的数量来验证它是否是主要元素。假设对于第一个元素,前几次检查显示 7 个不匹配的元素和 3 个匹配的元素。有必要继续检查这个元素吗?",
|
||||
|
Reference in New Issue
Block a user