mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-10-21 21:16:45 +08:00
update
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"translatedContent": "<p>给你两个 <strong>非递增</strong> 的整数数组 <code>nums1</code> 和 <code>nums2</code> ,数组下标均 <strong>从 0 开始</strong> 计数。</p>\n\n<p>下标对 <code>(i, j)</code> 中 <code>0 <= i < nums1.length</code> 且 <code>0 <= j < nums2.length</code> 。如果该下标对同时满足 <code>i <= j</code> 且 <code>nums1[i] <= nums2[j]</code> ,则称之为 <strong>有效</strong> 下标对,该下标对的 <strong>距离</strong> 为 <code>j - i</code> 。</p>\n\n<p>返回所有 <strong>有效</strong> 下标对<em> </em><code>(i, j)</code><em> </em>中的 <strong>最大距离</strong> 。如果不存在有效下标对,返回 <code>0</code> 。</p>\n\n<p>一个数组 <code>arr</code> ,如果每个 <code>1 <= i < arr.length</code> 均有 <code>arr[i-1] >= arr[i]</code> 成立,那么该数组是一个 <strong>非递增</strong> 数组。</p>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n\n<pre>\n<strong>输入:</strong>nums1 = [55,30,5,4,2], nums2 = [100,20,10,10,5]\n<strong>输出:</strong>2\n<strong>解释:</strong>有效下标对是 (0,0), (2,2), (2,3), (2,4), (3,3), (3,4) 和 (4,4) 。\n最大距离是 2 ,对应下标对 (2,4) 。\n</pre>\n\n<p><strong>示例 2:</strong></p>\n\n<pre>\n<strong>输入:</strong>nums1 = [2,2,2], nums2 = [10,10,1]\n<strong>输出:</strong>1\n<strong>解释:</strong>有效下标对是 (0,0), (0,1) 和 (1,1) 。\n最大距离是 1 ,对应下标对 (0,1) 。</pre>\n\n<p><strong>示例 3:</strong></p>\n\n<pre>\n<strong>输入:</strong>nums1 = [30,29,19,5], nums2 = [25,25,25,25,25]\n<strong>输出:</strong>2\n<strong>解释:</strong>有效下标对是 (2,2), (2,3), (2,4), (3,3) 和 (3,4) 。\n最大距离是 2 ,对应下标对 (2,4) 。\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 <= nums1.length <= 10<sup>5</sup></code></li>\n\t<li><code>1 <= nums2.length <= 10<sup>5</sup></code></li>\n\t<li><code>1 <= nums1[i], nums2[j] <= 10<sup>5</sup></code></li>\n\t<li><code>nums1</code> 和 <code>nums2</code> 都是 <strong>非递增</strong> 数组</li>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Medium",
|
||||
"likes": 22,
|
||||
"likes": 31,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
@@ -155,7 +155,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"11.7K\", \"totalSubmission\": \"17.9K\", \"totalAcceptedRaw\": 11680, \"totalSubmissionRaw\": 17910, \"acRate\": \"65.2%\"}",
|
||||
"stats": "{\"totalAccepted\": \"13.3K\", \"totalSubmission\": \"20.8K\", \"totalAcceptedRaw\": 13313, \"totalSubmissionRaw\": 20805, \"acRate\": \"64.0%\"}",
|
||||
"hints": [
|
||||
"Since both arrays are sorted in a non-increasing way this means that for each value in the first array. We can find the farthest value smaller than it using binary search.",
|
||||
"There is another solution using a two pointers approach since the first array is non-increasing the farthest j such that nums2[j] ≥ nums1[i] is at least as far as the farthest j such that nums2[j] ≥ nums1[i-1]"
|
||||
|
Reference in New Issue
Block a user