Python3 (First ,Helper and Second stacks) || O(n) || 100% Faster
\n\nclass Solution:\n    def secondGreaterElement(self, nums: List[int]) -> List[int]:\n        st1 = [] # monotonic decreasing first stack.\n        st2 = [] #
\n```\nclass Solution:\n    def secondGreaterElement(self, nums: List[int]) -> List[int]:\n        st1 = [] # monotonic decreasing first stack.\n        st2 = [] # Monotonic decreasing second stack.(having only that elements which have first greater)\n        helper = [] # monotonic increasing helper stack(help in moving elements from st1 to st2 with maintaining monotonicity of st2) \n        n = len(nums)\n        ans =[-1]*n\n        for i in range(n):\n            while st2 and nums[i]>nums[st2[-1]]: # if element can be second largest for st2 elements\n                ans[st2.pop()] = nums[i]\n            while st1 and nums[i]>nums[st1[-1]]: # if element can be second largest for st2 elements\n                helper.append(st1.pop())\n            while helper:\n                st2.append(helper.pop())    # for maintain monotonicity of st2\n            st1.append(i)\n        return ans   \n```\n**If like , Upvote :)**\n\n![image](https://assets.leetcode.com/users/images/3795acd7-665a-4f86-924a-6ac8cae9d0d7_1690658756.045314.png)\n
['Stack', 'Monotonic Stack', 'Python', 'Python3']