concise c++ solution using stack that beats 98%
\n vector<int> nextGreaterElements(vector<int>& nums) {\n        int n = nums.size();\n        vector<int> vec(n, -1);\n        stack<int> stack;\n        for(i
```   \n vector<int> nextGreaterElements(vector<int>& nums) {\n        int n = nums.size();\n        vector<int> vec(n, -1);\n        stack<int> stack;\n        for(int i=0, j=0; i<2*n-1; i++){\n            j = (i<n)?i:i-n;\n            while(!stack.empty() && nums[stack.top()]<nums[j]){\n                vec[stack.top()] = nums[j];\n                stack.pop();\n            }\n            if(i<n)stack.push(i);\n        }\n        return vec;\n    }\n```
[]