Foundations
Linear Structures
Hashing
Array and String Patterns
Recursion, Search, and Sorting
Problem Solving Patterns
Algorithm Searching
Sorting Algorithms
Array Algorithms
Grid Algorithms
Linear Structure Algorithms
Hashing Algorithms
Recursion and Backtracking
Greedy Algorithms
Tree and Heap Algorithms
Graph Algorithms
Dynamic Programming Algorithms
String Algorithms
Math Algorithms
Keyboard ready
Space plays. Arrow keys step. R restarts.
LAB Reverse Linked List Lab
Linked Lists
Problem shape
Beginner
7
->
11
->
18
->
24
Core idea
Walk the list and reverse each next pointer.
Step 1 / 5
Problem shape
Linked Lists Beginner
Reverse Linked List
Welcome to the Reverse Linked List algorithm lab. Walk the list and reverse each next pointer. Use it when: Use as a core pointer-manipulation exercise. The time complexity is O(n), and the space complexity is O(1). The pseudocode is: prev = null curr = head while curr is not null next = curr.next curr.next = prev prev = curr curr = next return prev As you practice, track the state that changes and the condition that makes the algorithm stop.
Time
O(n)
Space
O(1)
Pseudocode
prev = null
curr = head
while curr is not null
next = curr.next
curr.next = prev
prev = curr
curr = next
return prev 1.0x