✅Accepted | | ✅Easy solution || ✅Short & Simple || ✅Best Method
\n# Code\n\nclass Solution {\npublic:\n    vector<int> nextGreaterElements(vector<int>& nums) {\n        int n=nums.size();\n        vector<int> ans(n, -1);\n  
\n# Code\n```\nclass Solution {\npublic:\n    vector<int> nextGreaterElements(vector<int>& nums) {\n        int n=nums.size();\n        vector<int> ans(n, -1);\n        stack<int> st;\n        for(int i=0;i<2*n;i++)\n        {\n            while(!st.empty() && nums[i%n]>nums[st.top()%n])\n            {\n                ans[st.top()%n]=nums[i%n];\n                st.pop();\n            }\n            st.push(i%n);\n        }\n        return ans;\n    }\n};\n```\nPlease **UPVOTE** if it helps \u2764\uFE0F\uD83D\uDE0A\nThank You and Happy To Help You!!
['C++']