Given the head of a linked list, remove every node that has a node with a strictly greater value anywhere to its right. Return the head of the modified list as an array. (The result is a non-increasing sequence.)
Input: An array of node values.
Output: Array — the modified list.
Input: [5,2,13,3,8]
Output: [13,8]
Explanation: 5,2,3 each have a greater node to the right.Input: [1,1,1,1]
Output: [1,1,1,1]
Explanation: No strictly greater node on the right.Input: [1,2,3,4,5]
Output: [5]
Explanation: Only the maximum remains.1<=n<=10^51<=value<=10^5