EvalFrame Technical Mock Interviews & Coding Practice

Reverse Linked List

Easy · Linked List · Algorithm problem · all problems

Given the head of a singly linked list represented as an array of values, reverse the list and return the reversed list as an array. **Examples:** ```typescript reverseList([1, 2, 3, 4, 5]) // [5, 4, 3, 2, 1] reverseList([1, 2]) // [2, 1] reverseList([]) // [] ```

Solve It in the BrowserPractice Explaining It Out Loud

Optimal Approach

  • Time complexity: O(n)
  • Space complexity: O(1)

Single linear pass through the list of n elements in reverse order takes O(n) time.

Follow-Up Questions Interviewers Ask About Reverse Linked List

  • How do you reverse actual ListNode pointers in-place?
    Use three pointers: prev (null), curr (head), and next. In a loop, save curr.next, redirect curr.next = prev, advance prev = curr, and curr = next.

Practice the full problem with execution, tests, and AI code review in the interactive lab — then rehearse explaining your solution in a live voice mock interview.