Very Short and Simple Approach. 🔥
\nPLEASE UPVOTE IF U LIKE \uD83D\uDC4D\n\n# Complexity\n- Time complexity:O(n^2)\n\n- Space complexity:O(1) \njavascript []\n/**\n * @param {number[]} nums\n * 
```\nPLEASE UPVOTE IF U LIKE \uD83D\uDC4D\n```\n# Complexity\n- Time complexity:$$O(n^2)$$\n\n- Space complexity:$$O(1)$$ \n```javascript []\n/**\n * @param {number[]} nums\n * @return {number[]}\n */\nvar nextGreaterElements = function(nums) {\n    let ans = new Array(nums.length).fill(-1);\n        for (let i = 0; i < nums.length; i++) {\n            let j = (i + 1) % nums.length;\n            while (i !== j) {\n                if (nums[j] > nums[i]) {\n                    ans[i] = nums[j];\n                    break;\n                } else {\n                    j = (j + 1) % nums.length;\n                }\n            }\n        }\n        return ans;\n};\n\n```\n```python []\nclass Solution:\n    def nextGreaterElements(self, nums):\n        ans = [-1] * len(nums)\n        for i in range(len(nums)):\n            j = (i + 1) % len(nums)\n            while i != j:\n                if nums[j] > nums[i]:\n                    ans[i] = nums[j]\n                    break\n                else:\n                    j = (j + 1) % len(nums)\n        return ans\n\n```\n```c++ []\n#include <vector>\nusing namespace std;\n\nclass Solution {\npublic:\n    vector<int> nextGreaterElements(vector<int>& nums) {\n        vector<int> ans(nums.size(), -1);\n        for (int i = 0; i < nums.size(); ++i) {\n            int j = (i + 1) % nums.size();\n            while (i != j) {\n                if (nums[j] > nums[i]) {\n                    ans[i] = nums[j];\n                    break;\n                } else {\n                    j = (j + 1) % nums.size();\n                }\n            }\n        }\n        return ans;\n    }\n};\n\n```\n```java []\nclass Solution {\n    public int[] nextGreaterElements(int[] nums) {\n        int ans[] = new int[nums.length];\n        for(int i = 0 ; i<nums.length ; i++){\n            ans[i] = -1;\n            int j = (i+1)%nums.length;\n            while(i != j){\n                if(nums[j] > nums[i]){\n                    ans[i] = nums[j];\n                    break;\n                }\n                else{\n                    j = (j+1)%nums.length;\n                }\n            }\n        }\n        return ans;\n    }\n}\n```
['Python', 'C++', 'Java', 'JavaScript']