[Python 3]Heap + Monotonic queue (hint solution)
```\nclass Solution:\n    def secondGreaterElement(self, nums: List[int]) -> List[int]:        \n    \n        \n        n = len(nums)\n        first, second = 
```\nclass Solution:\n    def secondGreaterElement(self, nums: List[int]) -> List[int]:        \n    \n        \n        n = len(nums)\n        first, second = [], []\n        ans = [-1] * n\n        \n        for i in range(n):\n            # check if current greater than candidates waiting for second greater element\n            while second and nums[i] > second[0][0]:\n                val, idx = heappop(second)\n                ans[idx] = nums[i]\n            \n            # check if current greater than candidates waiting for first greater element\n            while first and nums[i] > nums[first[-1]]:\n                tmp = first.pop()\n                # push into candidates waiting for second greater element\n                # min-heap with smallest value on top\n                heappush(second, (nums[tmp], tmp))\n            first.append(i)\n        \n        \n        return ans
['Heap (Priority Queue)', 'Monotonic Queue', 'Python', 'Python3']