Skip to content
CampusEduX

Insert at Beginning of Linked List

Easyjavapythonccppjavascript

Given a linked list and a value X, insert a new node containing X at the beginning and print the resulting list.

Input Format

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

Output Format

Print the updated list from head to tail, separated by single spaces.

Related Problems

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

Input (stdin)

Output

Run your code to see output here...