Given an array nums, for each element return the next strictly greater element to its right, or -1 if none exists. Return the array of answers. The input is JSON {nums}.
Input: JSON {nums}.
Output: Array — the next greater element for each position.
Input: {"nums":[2,1,2,4,3]}
Output: [4,2,4,-1,-1]
Explanation: Nearest greater to the right of each.Input: {"nums":[5]}
Output: [-1]
Explanation: No element to the right.Input: {"nums":[1,2,3,4]}
Output: [2,3,4,-1]
Explanation: Each is followed by a greater.1<=n<=10^5