2026-06-01 18:12:40 +08:00
#+ANKI_DECK : study_deck_02
2026-06-01 17:12:10 +08:00
* TODO 1871. Jump Game VII :medium:
2026-06-01 02:33:30 +08:00
:PROPERTIES:
2026-06-01 17:22:07 +08:00
:NEETCODE: [[file:../../roadmap.org::*1871. Jump Game VII][1871. Jump Game VII]]
2026-06-01 02:33:30 +08:00
:END:
2026-06-01 17:22:07 +08:00
You are given a *0-indexed* binary string ~s~ and two integers ~minJump~ and ~maxJump~ . In the beginning, you are standing at index ~0~ , which is equal to ~'0'~ . You can move from index ~i~ to index ~j~ if the following conditions are fulfilled:
- ~i + minJump <= j <= min(i + maxJump, s.length - 1)~ , and
- ~s[j] == '0'~ .
Return ~true~ if you can reach index ~s.length - 1~ in ~s~ /, or / ~false~ / otherwise./
*Example 1:*
#+begin_ src
Input: s = "011010", minJump = 2, maxJump = 3
Output: true
Explanation:
In the first step, move from index 0 to index 3.
In the second step, move from index 3 to index 5.
#+end_src
*Example 2:*
#+begin_ src
Input: s = "01101110", minJump = 2, maxJump = 3
Output: false
#+end_src
*Constraints:*
- ~2 <= s.length <= 10^{5}~
- ~s[i]~ is either ~'0'~ or ~'1'~ .
- ~s[0] == '0'~
- ~1 <= minJump <= maxJump < s.length~
2026-06-01 02:39:53 +08:00
** TODO Approach
Write your approach here.
** TODO Python
2026-06-05 22:32:49 +08:00
#+begin_src python :lc-problem 1871 :lc-lang python3
2026-06-01 17:22:07 +08:00
class Solution :
def canReach ( self , s : str , minJump : int , maxJump : int ) - > bool :
2026-06-01 02:39:53 +08:00
#+end_src
** TODO C++
2026-06-05 22:32:49 +08:00
#+begin_src cpp :lc-problem 1871
2026-06-01 17:22:07 +08:00
class Solution {
public :
bool canReach ( string s , int minJump , int maxJump ) {
}
} ;
2026-06-01 02:33:30 +08:00
#+end_src