Trains the technique from
LeetCode 1871Jump Game VIIThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A temporary walkway across a channel is described by s, one character per pontoon along the line. '0' marks a pontoon that still floats and can be stood on, '1' marks one that has gone under and cannot.
A surveyor starts on pontoon 0, which always floats. From the pontoon at index i the surveyor may hop to the pontoon at index j when all of the following hold:
i + minJump <= j <= i + maxJump,j is within the walkway, so j <= s.length - 1,s[j] is '0'.Hops are always forward and there is no limit on how many are taken.
Return true if the surveyor can arrive at the last pontoon, index s.length - 1, and false if no series of hops gets there.
Example 1
Hopping 0 -> 2 -> 4 -> 7 uses spans of 2, 2 and 3, and pontoons 2, 4 and 7 all float, so the far side is reached.
Example 2
Every hop covers exactly two pontoons, so the only landing from pontoon 0 is pontoon 2, which is under water, and the surveyor is stuck at the start.
Example 3
A single hop of three lands directly on pontoon 3, which floats.
Example 4
The last pontoon is submerged, so it cannot be stood on and the crossing fails.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def can_cross_channel(deck: str, min_span: int, max_span: int) -> bool:public boolean canCrossChannel(String deck, int minSpan, int maxSpan)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.