Easy Peasy Solution || C++ || Like Next Greater Element || Faster than 87.50%
First find next greater element for each element in the array\n2. Store them into an array , here I used nextBig[ ]\n3. Now just find second next greater elemen
1. First find next greater element for each element in the array\n2. Store them into an array , here I used nextBig[ ]\n3. Now just find second next greater element\n\nPlease upvote if you find it useful.. :)\n\nHappy Coding :)\n\n```\nclass Solution {\npublic:\n    vector<int> secondGreaterElement(vector<int>& nums) {\n        int n = nums.size();\n        \n        int nextBig[n+4];\n        nextBig[n-1]=n;\n        nextBig[n]=n;\n        for(int i=n-1; i>=0; i--)\n        {\n            int pos;\n            pos = i+1;\n            while(pos<n && nums[pos]<= nums[i]  ){\n                pos = nextBig[pos];\n            }\n            nextBig[i]=pos;\n        }\n        vector<int>ans(n);\n        int pos;\n        for(int i=0; i<n; i++)\n        {\n            pos = nextBig[i];\n            pos++;\n           \n            while(pos<n && nums[pos]<=nums[i]){\n                pos = nextBig[pos];\n            }\n           \n                \n            if(pos<n) ans[i]=nums[pos];\n            else ans[i]=-1;\n        }\n        \n        \n        return ans;\n    }\n};\n```
['C']