Reverse Linked List
Easy
Linked Lists
Linked List
Reverse a singly linked list. Given space-separated values, output reversed values.
Constraints
0 ≤ nodes ≤ 5000
Examples
Example 1:
Input: 1 2 3 4 5
Output: 5 4 3 2 1
Example 2:
Input: 1 2
Output: 2 1
Tests:
Runtime:
Memory:
Test
Input:
Expected:
Got:
Click Run Code to test against sample cases, or Submit to test against all cases.
▲ Console