Reverse a Linked List

easy
Unit 7 · BFS I0/4 to milestone

Using the provided ListNode, implement:

  • reverse(head): reverse the whole list iteratively, returning the new head
  • reverse_between(head, left, right): reverse only positions left..right (1-based, inclusive) in one pass, returning the head

Helpers from_list and to_list are provided for testing.

#linked-lists#pointers2 visible + 1 hidden tests
solution.py · Python 3.13
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Reverse a Linked List · TechGradify