mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-04 15:01:40 +08:00
update
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"translatedContent": "<p>有一只跳蚤的家在数轴上的位置 <code>x</code> 处。请你帮助它从位置 <code>0</code> 出发,到达它的家。</p>\n\n<p>跳蚤跳跃的规则如下:</p>\n\n<ul>\n\t<li>它可以 <strong>往前</strong> 跳恰好 <code>a</code> 个位置(即往右跳)。</li>\n\t<li>它可以 <strong>往后</strong> 跳恰好 <code>b</code> 个位置(即往左跳)。</li>\n\t<li>它不能 <strong>连续</strong> 往后跳 <code>2</code> 次。</li>\n\t<li>它不能跳到任何 <code>forbidden</code> 数组中的位置。</li>\n</ul>\n\n<p>跳蚤可以往前跳 <strong>超过</strong> 它的家的位置,但是它 <strong>不能跳到负整数</strong> 的位置。</p>\n\n<p>给你一个整数数组 <code>forbidden</code> ,其中 <code>forbidden[i]</code> 是跳蚤不能跳到的位置,同时给你整数 <code>a</code>, <code>b</code> 和 <code>x</code> ,请你返回跳蚤到家的最少跳跃次数。如果没有恰好到达 <code>x</code> 的可行方案,请你返回 <code>-1</code> 。</p>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n\n<pre>\n<b>输入:</b>forbidden = [14,4,18,1,15], a = 3, b = 15, x = 9\n<b>输出:</b>3\n<b>解释:</b>往前跳 3 次(0 -> 3 -> 6 -> 9),跳蚤就到家了。\n</pre>\n\n<p><strong>示例 2:</strong></p>\n\n<pre>\n<b>输入:</b>forbidden = [8,3,16,6,12,20], a = 15, b = 13, x = 11\n<b>输出:</b>-1\n</pre>\n\n<p><strong>示例 3:</strong></p>\n\n<pre>\n<b>输入:</b>forbidden = [1,6,2,14,5,17,4], a = 16, b = 9, x = 7\n<b>输出:</b>2\n<b>解释:</b>往前跳一次(0 -> 16),然后往回跳一次(16 -> 7),跳蚤就到家了。\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 <= forbidden.length <= 1000</code></li>\n\t<li><code>1 <= a, b, forbidden[i] <= 2000</code></li>\n\t<li><code>0 <= x <= 2000</code></li>\n\t<li><code>forbidden</code> 中所有位置互不相同。</li>\n\t<li>位置 <code>x</code> 不在 <code>forbidden</code> 中。</li>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Medium",
|
||||
"likes": 46,
|
||||
"likes": 48,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
@@ -149,7 +149,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"5K\", \"totalSubmission\": \"17.1K\", \"totalAcceptedRaw\": 5041, \"totalSubmissionRaw\": 17067, \"acRate\": \"29.5%\"}",
|
||||
"stats": "{\"totalAccepted\": \"5.3K\", \"totalSubmission\": \"18K\", \"totalAcceptedRaw\": 5349, \"totalSubmissionRaw\": 17956, \"acRate\": \"29.8%\"}",
|
||||
"hints": [
|
||||
"Think of the line as a graph",
|
||||
"to handle the no double back jumps condition you can handle it by holding the state of your previous jump"
|
||||
|
Reference in New Issue
Block a user