Python Simple O(n) Solution (Monotonic Stack)
\nclass Solution:\n    def nextGreaterElements(self, nums: List[int]) -> List[int]:\n        n = len(nums)\n        ans = n * [-1]\n        nums += nums\n      
```\nclass Solution:\n    def nextGreaterElements(self, nums: List[int]) -> List[int]:\n        n = len(nums)\n        ans = n * [-1]\n        nums += nums\n        \n        stack = []\n        for i, num in enumerate(nums):\n            while stack and stack[-1][1] < num:\n                ans[stack.pop()[0]] = num\n            if i < n: stack.append((i, num))\n        \n        return ans\n```\n\nn = length of nums\nTime complexity: O(2 * n) = O(n)\nSpace complexity: O(n)
['Monotonic Stack', 'Python']