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": "已知一个长度为 <code>n</code> 的数组,预先按照升序排列,经由 <code>1</code> 到 <code>n</code> 次 <strong>旋转</strong> 后,得到输入数组。例如,原数组 <code>nums = [0,1,2,4,5,6,7]</code> 在变化后可能得到:\n<ul>\n\t<li>若旋转 <code>4</code> 次,则可以得到 <code>[4,5,6,7,0,1,2]</code></li>\n\t<li>若旋转 <code>7</code> 次,则可以得到 <code>[0,1,2,4,5,6,7]</code></li>\n</ul>\n\n<p>注意,数组 <code>[a[0], a[1], a[2], ..., a[n-1]]</code> <strong>旋转一次</strong> 的结果为数组 <code>[a[n-1], a[0], a[1], a[2], ..., a[n-2]]</code> 。</p>\n\n<p>给你一个元素值 <strong>互不相同</strong> 的数组 <code>nums</code> ,它原来是一个升序排列的数组,并按上述情形进行了多次旋转。请你找出并返回数组中的 <strong>最小元素</strong> 。</p>\n\n<p>你必须设计一个时间复杂度为 <code>O(log n)</code> 的算法解决此问题。</p>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n\n<pre>\n<strong>输入:</strong>nums = [3,4,5,1,2]\n<strong>输出:</strong>1\n<strong>解释:</strong>原数组为 [1,2,3,4,5] ,旋转 3 次得到输入数组。\n</pre>\n\n<p><strong>示例 2:</strong></p>\n\n<pre>\n<strong>输入:</strong>nums = [4,5,6,7,0,1,2]\n<strong>输出:</strong>0\n<strong>解释:</strong>原数组为 [0,1,2,4,5,6,7] ,旋转 4 次得到输入数组。\n</pre>\n\n<p><strong>示例 3:</strong></p>\n\n<pre>\n<strong>输入:</strong>nums = [11,13,15,17]\n<strong>输出:</strong>11\n<strong>解释:</strong>原数组为 [11,13,15,17] ,旋转 4 次得到输入数组。\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>n == nums.length</code></li>\n\t<li><code>1 <= n <= 5000</code></li>\n\t<li><code>-5000 <= nums[i] <= 5000</code></li>\n\t<li><code>nums</code> 中的所有整数 <strong>互不相同</strong></li>\n\t<li><code>nums</code> 原来是一个升序排序的数组,并进行了 <code>1</code> 至 <code>n</code> 次旋转</li>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Medium",
|
||||
"likes": 707,
|
||||
"likes": 737,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[{\"title\": \"Search in Rotated Sorted Array\", \"titleSlug\": \"search-in-rotated-sorted-array\", \"difficulty\": \"Medium\", \"translatedTitle\": \"\\u641c\\u7d22\\u65cb\\u8f6c\\u6392\\u5e8f\\u6570\\u7ec4\"}, {\"title\": \"Find Minimum in Rotated Sorted Array II\", \"titleSlug\": \"find-minimum-in-rotated-sorted-array-ii\", \"difficulty\": \"Hard\", \"translatedTitle\": \"\\u5bfb\\u627e\\u65cb\\u8f6c\\u6392\\u5e8f\\u6570\\u7ec4\\u4e2d\\u7684\\u6700\\u5c0f\\u503c II\"}]",
|
||||
@@ -143,7 +143,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"266.3K\", \"totalSubmission\": \"468.4K\", \"totalAcceptedRaw\": 266343, \"totalSubmissionRaw\": 468450, \"acRate\": \"56.9%\"}",
|
||||
"stats": "{\"totalAccepted\": \"277.4K\", \"totalSubmission\": \"487.7K\", \"totalAcceptedRaw\": 277425, \"totalSubmissionRaw\": 487681, \"acRate\": \"56.9%\"}",
|
||||
"hints": [
|
||||
"Array was originally in ascending order. Now that the array is rotated, there would be a point in the array where there is a small deflection from the increasing sequence. eg. The array would be something like [4, 5, 6, 7, 0, 1, 2].",
|
||||
"You can divide the search space into two and see which direction to go.\r\nCan you think of an algorithm which has O(logN) search complexity?",
|
||||
|
Reference in New Issue
Block a user