New update is available. Click here to update.

Left Short

Posted: 3 Oct, 2020
Difficulty: Easy


Try Problem

You are given a Singly Linked List of integers. Modify the linked list by removing the nodes from the list that have a greater valued node on their adjacent left in the given linked list.

Input Format
The first line of the input contains 'L' space-separated integers denoting the elements of the singly linked list terminated by -1.

Hence, -1 would never be a list element.
Output Format:
Print the modified linked list. The elements of the modified list should be single-space separated, terminated by -1.
You don’t need to print anything; It has already been taken care of. Just implement the given function.
0 <= L <= 5 * 10^5
-10^9 <= <= 10^9 and data != -1

Where 'L' is the number of nodes in the Linked-List.

Time Limit : 1 sec