Class Solution
java.lang.Object
g2401_2500.s2487_remove_nodes_from_linked_list.Solution
2487 - Remove Nodes From Linked List.<p>Medium</p>
<p>You are given the <code>head</code> of a linked list.</p>
<p>Remove every node which has a node with a <strong>strictly greater</strong> value anywhere to the right side of it.</p>
<p>Return <em>the</em> <code>head</code> <em>of the modified linked list.</em></p>
<p><strong>Example 1:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2022/10/02/drawio.png" alt="" /></p>
<p><strong>Input:</strong> head = [5,2,13,3,8]</p>
<p><strong>Output:</strong> [13,8]</p>
<p><strong>Explanation:</strong> The nodes that should be removed are 5, 2 and 3.</p>
<ul>
<li>Node 13 is to the right of node 5.</li>
<li>Node 13 is to the right of node 2.</li>
<li>Node 8 is to the right of node 3.</li>
</ul>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> head = [1,1,1,1]</p>
<p><strong>Output:</strong> [1,1,1,1]</p>
<p><strong>Explanation:</strong> Every node has value 1, so no nodes are removed.</p>
<p><strong>Constraints:</strong></p>
<ul>
<li>The number of the nodes in the given list is in the range <code>[1, 10<sup>5</sup>]</code>.</li>
<li><code>1 <= Node.val <= 10<sup>5</sup></code></li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
removeNodes
-