Python Monotonic Stack O(n) Approach
Monotonic Decreasing Stack : reference from here\n\n|  next greater      |  decreasing (equal allowed)  |  stackTop < current     |  inside while loop    |\n\nc
Monotonic Decreasing Stack : reference from [here](https://leetcode.com/discuss/study-guide/2347639/a-comprehensive-guide-and-template-for-monotonic-stack-based-problems)\n\n|  next greater      |  decreasing (equal allowed)  |  stackTop < current     |  inside while loop    |\n\nconcept : same as [496. Next Greater Element I\n](https://leetcode.com/problems/next-greater-element-i/) but perform it twice.\n```\nclass Solution:\n    def nextGreaterElements(self, nums: List[int]) -> List[int]:\n        stack = []\n        res = [-1] * len(nums)\n        \n        for _ in range(2):\n            for i in range(len(nums)):\n                while stack and nums[stack[-1]] < nums[i]:\n                    idx = stack.pop()\n                    res[idx] = nums[i]\n                stack.append(i)\n        \n        return res\n    \n```
['Monotonic Stack', 'Python']