Given two arrays nums1 (subset) and nums2, for each x in nums1, find the next greater element to its right in nums2. Return -1 if none exists.
This problem demonstrates the monotonic stack pattern: scan nums2 once keeping a decreasing stack of values, and resolve each one's next-greater as a bigger value arrives.
1 ≤ nums1.length ≤ nums2.length ≤ 10⁴0 ≤ nums1[i], nums2[i] ≤ 10⁴nums1 are unique, and so are those within nums2.nums1 also appears in nums2.Process nums2 with a monotonic stack to build a value → next-greater map.