Class Solution
java.lang.Object
g1001_1100.s1019_next_greater_node_in_linked_list.Solution
1019 - Next Greater Node In Linked List.<p>Medium</p>
<p>You are given the <code>head</code> of a linked list with <code>n</code> nodes.</p>
<p>For each node in the list, find the value of the <strong>next greater node</strong>. That is, for each node, find the value of the first node that is next to it and has a <strong>strictly larger</strong> value than it.</p>
<p>Return an integer array <code>answer</code> where <code>answer[i]</code> is the value of the next greater node of the <code>i<sup>th</sup></code> node ( <strong>1-indexed</strong> ). If the <code>i<sup>th</sup></code> node does not have a next greater node, set <code>answer[i] = 0</code>.</p>
<p><strong>Example 1:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2021/08/05/linkedlistnext1.jpg" alt="" /></p>
<p><strong>Input:</strong> head = [2,1,5]</p>
<p><strong>Output:</strong> [5,5,0]</p>
<p><strong>Example 2:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2021/08/05/linkedlistnext2.jpg" alt="" /></p>
<p><strong>Input:</strong> head = [2,7,4,3,5]</p>
<p><strong>Output:</strong> [7,0,5,5,0]</p>
<p><strong>Constraints:</strong></p>
<ul>
<li>The number of nodes in the list is <code>n</code>.</li>
<li><code>1 <= n <= 10<sup>4</sup></code></li>
<li><code>1 <= Node.val <= 10<sup>9</sup></code></li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
nextLargerNodes
-