Approach hintTry it first, then revealHide
Compute the next greater element for every value of nums2 with a decreasing stack, store the results in a hash map, and look up each element of nums1.
Compute the next greater element for every value of nums2 with a decreasing stack, store the results in a hash map, and look up each element of nums1.