1. Given a linked list with head as the first node. 2. Return an integer array containing next greaater value corresponding every node's value . 3. If there is no greater value then put 0 corresponding to its position.
Input Format
ListNode head(Head of the linkedlist) is given to you as the argument. For custom input: 1. Size of the linked list. 2. Space separated integer values to be inserted in your linked list in order.
Output Format
An integer array.
Constraints
Constraints is handled for you
Notice
Try First, Check Solution later
1. You should first read the question and watch the question video.2. Think of a solution approach, then try and submit the question on editor tab.3. We strongly advise you to watch the solution video for prescribed approach.Example
Input
3 2 1 5
Output
5 5 0