Super Easy JAVA Sol.(Stack)
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(N)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(N)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public int[] nextGreaterElements(int[] nums) {\n        int n = nums.length;\n        int[] res = new int[n];\n        Stack<Integer> s = new Stack<>();\n        // we double the length of loop to imitate a circular array\n        // just remember to use i%n for indexing\n        for (int i = 2*n; i>=0; i--) {\n            while (!s.isEmpty() && s.peek() <= nums[i%n]) {\n                s.pop();\n            }\n            res[i%n] = s.isEmpty() ? -1 : s.peek();\n            s.push(nums[i%n]);\n        }\n        return res;\n\n    }\n}\n```
['Java']