Simply Simple Python Solution - two pass - O(n) - Stack
\tdef nextGreaterElements(self, nums: List[int]) -> List[int]:\n        ln = len(nums)\n        if ln == 0:\n            return []\n        stack = []\n        
\tdef nextGreaterElements(self, nums: List[int]) -> List[int]:\n        ln = len(nums)\n        if ln == 0:\n            return []\n        stack = []\n        res = [-1] * ln\n        # Run it twice. After first iteration\n        # the stack has the increasing order of elements from starting\n        # so in second iteration you will get the next greater from stack\n        # which was on the left side of that node\n        for _ in range(2):\n            for i in range(ln - 1, -1, -1):\n                while len(stack) > 0 and stack[-1] <= nums[i]:\n                    stack.pop()\n                if len(stack) > 0:\n                    res[i] = stack[-1]\n                    \n                stack.append(nums[i])\n                \n        return res
['Python', 'Python3']