1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-02 14:12:17 +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>给定整数 <code>n</code> ,返回 <em>所有小于非负整数&nbsp;<code>n</code>&nbsp;的质数的数量</em> 。</p>\n\n<p>&nbsp;</p>\n\n<p><strong>示例 1</strong></p>\n\n<pre>\n<strong>输入:</strong>n = 10\n<strong>输出:</strong>4\n<strong>解释:</strong>小于 10 的质数一共有 4 个, 它们是 2, 3, 5, 7 。\n</pre>\n\n<p><strong>示例 2</strong></p>\n\n<pre>\n<strong>输入:</strong>n = 0\n<strong>输出:</strong>0\n</pre>\n\n<p><strong>示例 3</strong></p>\n\n<pre>\n<strong>输入:</strong>n = 1\n<strong>输出</strong>0\n</pre>\n\n<p>&nbsp;</p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>0 &lt;= n &lt;= 5 * 10<sup>6</sup></code></li>\n</ul>\n",
"isPaidOnly": false,
"difficulty": "Medium",
"likes": 852,
"likes": 875,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[{\"title\": \"Ugly Number\", \"titleSlug\": \"ugly-number\", \"difficulty\": \"Easy\", \"translatedTitle\": \"\\u4e11\\u6570\"}, {\"title\": \"Ugly Number II\", \"titleSlug\": \"ugly-number-ii\", \"difficulty\": \"Medium\", \"translatedTitle\": \"\\u4e11\\u6570 II\"}, {\"title\": \"Perfect Squares\", \"titleSlug\": \"perfect-squares\", \"difficulty\": \"Medium\", \"translatedTitle\": \"\\u5b8c\\u5168\\u5e73\\u65b9\\u6570\"}]",
@@ -155,7 +155,7 @@
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"192.6K\", \"totalSubmission\": \"512.3K\", \"totalAcceptedRaw\": 192634, \"totalSubmissionRaw\": 512306, \"acRate\": \"37.6%\"}",
"stats": "{\"totalAccepted\": \"198.7K\", \"totalSubmission\": \"529.7K\", \"totalAcceptedRaw\": 198708, \"totalSubmissionRaw\": 529721, \"acRate\": \"37.5%\"}",
"hints": [
"<p>Let's start with a <i>isPrime</i> function. To determine if a number is prime, we need to check if it is not divisible by any number less than <i>n</i>. The runtime complexity of <i>isPrime</i> function would be O(<i>n</i>) and hence counting the total prime numbers up to <i>n</i> would be O(<i>n</i><sup>2</sup>). Could we do better?</p>",
"<p>As we know the number must not be divisible by any number > <i>n</i> / 2, we can immediately cut the total iterations half by dividing only up to <i>n</i> / 2. Could we still do better?</p>",