[
linked list
two pointers
]
BinarySearch 0618 Linked List Jumps
Problem statement
https://binarysearch.com/problems/Linked-List-Jumps/
Solution
Just do what is asked with two pointers.
Complexity
It is O(n)
for time and O(1)
for space.
Code
class Solution:
def solve(self, node):
head, curr = node, node
while curr:
last, cnt = curr, 0
while cnt < last.val and curr:
curr = curr.next
cnt += 1
last.next = curr
return head