You are given the head of a singly linked list containing n nodes.
For each node in the list, find the value of the next greater node. The next greater node of a given node is the first node located after it in the list whose value is strictly greater than its value. If no subsequent node has a strictly greater value, the answer for that node is
Return an array of integers representing the next greater node value for each node in the list, ordered from the first node to the last.
Constraints:
The number of nodes in the list is n.
n
Node.val
You are given the head of a singly linked list containing n nodes.
For each node in the list, find the value of the next greater node. The next greater node of a given node is the first node located after it in the list whose value is strictly greater than its value. If no subsequent node has a strictly greater value, the answer for that node is
Return an array of integers representing the next greater node value for each node in the list, ordered from the first node to the last.
Constraints:
The number of nodes in the list is n.
n
Node.val