Skip to content
CampusEduX

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.

Related Problems

  • Create and Traverse a Linked List
    Easy · java, python, c, cpp, javascript
    Solve Problem
  • Insert at Beginning of Linked List
    Easy · java, python, c, cpp, javascript
    Solve Problem
  • Insert at End of Linked List
    Easy · java, python, c, cpp, javascript
    Solve Problem

Input (stdin)

Output

Run your code to see output here...