Next Largest Number to the Right
Medium
Given an integer array nums, return an output array res where, for each value nums[i], res[i] is the first number to the right that's larger than nums[i]. If no larger number exists to the right of nums[i], set res[i] to ‐1.
Example:
Input: nums = [5, 2, 4, 6, 1]
Output: [6, 4, 6, -1, -1]