java simple solution
```\nclass Solution {\n    public int[] nextGreaterElements(int[] nums) {\n        \n        Stack value = new Stack<>();\n        for(int i = nums.length - 1; 
```\nclass Solution {\n    public int[] nextGreaterElements(int[] nums) {\n        \n        Stack<Integer> value = new Stack<>();\n        for(int i = nums.length - 1; i >= 0; --i) {\n            value.push(nums[i]);\n        }\n        \n        int[] result = new int[nums.length];\n        for(int i = nums.length - 1; i >= 0; --i) {\n            while(!value.isEmpty() && value.peek() <= nums[i]) {\n                value.pop();    \n            }\n            \n            int right = (value.isEmpty()) ? -1 : value.peek();\n            result[i] = right;\n            value.push(nums[i]);\n        }\n        return result;\n    }\n}
[]