Linked List Jumps
You are given a singly linked list node
containing positive integers. Return the same linked list where every node’s next
points to the node val
nodes ahead. If there’s no such node, next
should point to null.
Constraints
n ≤ 100,000
wheren
is the number of nodes innode
https://binarysearch.com/problems/Linked-List-Jumps
Examples
Example 1
Input
- node =
Output
- answer =
Explanation
Note that 2
’s next is 2
node ahead. 4
’s next is out of bounds, so it’s set to null.
Leave a comment