2487. Remove Nodes From Linked List
Medium
You are given the head
of a linked list.
Remove every node which has a node with a strictly greater value anywhere to the right side of it.
Return the head
of the modified linked list.
Example 1:
Example 2:
Constraints:
The number of the nodes in the given list is in the range
[1, 105]
.1 <= Node.val <= 10^5
解題
先用 stack 消去比 head 小的節點,接著將 stack 內剩下的節點連在一起。
Previous2486. Append Characters to String to Make SubsequenceNext2491. Divide Players Into Teams of Equal Skill
Last updated