✔️ Java 100% Fastest - Easy Solution using Stack
\nclass Solution {\n    public int[] nextGreaterElements(int[] nums) {\n        int[] ans = new int[nums.length];\n        Stack<Integer> stack = new Stack<Inte
```\nclass Solution {\n    public int[] nextGreaterElements(int[] nums) {\n        int[] ans = new int[nums.length];\n        Stack<Integer> stack = new Stack<Integer>();\n        int len = nums.length;\n        for(int i = (2*len)-1 ; i >= 0 ; i--){\n            while(stack.size() != 0 && stack.peek() <= nums[i%len]){\n                stack.pop();\n            }\n            if(i < len){\n                if(stack.size() != 0){\n                    ans[i%len] = stack.peek();\n                }\n                else{\n                    ans[i%len] = -1;\n                }\n            }\n            stack.push(nums[i%len]);\n        }\n        return ans;\n    }\n}\n```
['Stack', 'Monotonic Stack', 'Java']