Skip to content
C

Reverse a Linked List

Easyjavapythonccppjavascript

Given the head of a singly linked list, reverse all links and print the reversed list.

Input Format

The first line contains an integer N. The second line contains N space-separated integers (empty if N is 0).

Output Format

Print the reversed list from head to tail, separated by single spaces. Print an empty line if the list is empty.

Input (stdin)

Output

Run your code to see output here...