Dsa
Linked List
Warm-up
Reverse a Linked List
Given a linked list, reverse the order of its nodes in the list. You need to output the values in the reverse order, separated by spaces.
Input format:
- The first line contains an integer n (0 <= n <= 100), the number of nodes.
- The second line contains n space-separated integers, representing the values of each node in the linked list.
Output format:
- A single line with the values in reverse order, separated by spaces.
Example:
Input:
5
1 2 3 4 5
Output:
5 4 3 2 1
Key concepts
linked_listreversaltraversal
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now