[Python3] Good enough
python3 []\nclass Solution:\n    def secondGreaterElement(self, nums: List[int]) -> List[int]:\n        final = [-1]*len(nums)\n        stack = [0]\n        hea
```python3 []\nclass Solution:\n    def secondGreaterElement(self, nums: List[int]) -> List[int]:\n        final = [-1]*len(nums)\n        stack = [0]\n        heap = []\n\n        for i in range(1, len(nums)):\n            while heap and heap[0][0]<nums[i]:\n                final[heapq.heappop(heap)[1]] = nums[i]\n\n            if stack and nums[i]>nums[stack[-1]]:\n                while stack and nums[i]>nums[stack[-1]]:\n                    j = stack.pop()\n                    heapq.heappush(heap, (nums[j], j))\n\n            stack.append(i)\n        \n        return final\n```
['Python3']