@@ -0,0 +1,1798 @@
+/**%0A *You are given two arrays (without duplicates) nums1 and nums2 where nums1%E2%80%99s elements are subset of nums2. Find all the next greater numbers for nums1's elements in the corresponding places of nums2.%0A *%0A *The Next Greater Number of a number x in nums1 is the first greater number to its right in nums2. If it does not exist, output -1 for this number.%0A *%0A *Example 1:%0A *Input: nums1 = %5B4,1,2%5D, nums2 = %5B1,3,4,2%5D.%0A *Output: %5B-1,3,-1%5D%0A *Explanation:%0A *    For number 4 in the first array, you cannot find the next greater number for it in the second array, so output -1.%0A *    For number 1 in the first array, the next greater number for it in the second array is 3.%0A *    For number 2 in the first array, there is no next greater number for it in the second array, so output -1.%0A *Example 2:%0A *Input: nums1 = %5B2,4%5D, nums2 = %5B1,2,3,4%5D.%0A *Output: %5B3,-1%5D%0A *Explanation:%0A *    For number 2 in the first array, the next greater number for it in the second array is 3.%0A *    For number 4 in the first array, there is no next greater number for it in the second array, so output -1.%0A *Note:%0A *All elements in nums1 and nums2 are unique.%0A *The length of both nums1 and nums2 would not exceed 1000.%0A */%0Aclass Solution %7B%0A    public int%5B%5D nextGreaterElement(int%5B%5D nums1, int%5B%5D nums2) %7B%0A       Map%3CInteger, Integer%3E map = new HashMap%3C%3E();%0A       Stack%3CInteger%3E stack = new Stack%3C%3E();%0A       for (int num : nums2) %7B%0A           while (!stack.empty() && num %3E stack.peek()) %7B%0A               map.put(stack.pop(), num);%0A           %7D%0A           stack.push(num);%0A       %7D%0A        %0A      for (int i = 0; i %3C nums1.length; i++) %7B%0A          if (map.containsKey(nums1%5Bi%5D)) %7B%0A              nums1%5Bi%5D = map.get(nums1%5Bi%5D);%0A          %7D else %7B%0A              nums1%5Bi%5D = -1;%0A          %7D%0A      %7D%0A      return nums1;  %0A    %7D%0A%7D%0A

Create NextGreaterElementI.java