Javascript Solution beats 84.78 %, TC - O(N) , SC - O(N)
// -------------------------------- APPROACH -------------------------------- \\\n    \n Iterate from the last element :\n1.     Check if there is any element l
// -------------------------------- APPROACH -------------------------------- \\\\\n    \n Iterate from the last element :\n1.     Check if there is any element lesser than current element in the satck \n             a. If No lesser element found & the stack is empty, fill that index with -1.\n\t\t\t     Then Insert the curr element into the stack.\n             b. If No lesser element found & the stack has greater element than current, fill that index with the stack\'s top element. \n\t\t\t     push the curr element into the stack.\n             c. If there is less element keep removing from the top of the stack until you find the next greater element.\n\t\t\t     Fill that index with stack\'s top element and insert the current element into the stack \n\n            \n2.     For traversing in circular fashion, Do i % n\n    \n  */\n    \n    TIME COMPLEXITY = O(2N) + O(2N) ~~ O(N)\n    SPACE COMPLEXITY = O(N)\n    \n    \n    // -------------------------------- STACK SOLUTION -------------------------------- \\\\\n    \n    var nextGreaterElements = function(nums) {\n      let stack = [];\n      let output = [];\n    \n     for(let i=2*(nums.length-1); i>=0; i--) {\n        \n        let Index = i % nums.length;\n        while(stack.length > 0 && nums[Index] >= nums[stack[stack.length-1]]) {\n           \n            stack.pop();\n        }\n        \n        if(stack.length === 0){\n            output[Index] = -1;\n        }else{\n            output[Index] = nums[stack[stack.length-1]]\n        }\n        \n        stack.push(Index);\n     }\n    \n     return output;\n\t}
['Stack', 'JavaScript']