Next Greater Element
Try to solve the Next Greater Element I problem.
Understand the problem
Let’s take a moment to make sure you’ve correctly understood the problem. The quiz below helps you check if you’re solving the correct problem:
Next Greater Element
1.
What is the output if the following arrays are given as input?
nums1 = [5, 4, 7]
nums2 = [4, 5, 7, 3]
A.
ans = [7, 7, 3]
B.
ans = [7, 7, -1]
C.
ans = [7, 5, -1]
D.
ans = [7, 5, 3]
1 / 3
Figure it out!
We have a game for you to play. Rearrange the logical building blocks to develop a clearer understanding of how to solve this problem.
Try it yourself
Implement your solution in the following coding playground.
JavaScript
usercode > main.js
function nextGreaterElement(nums1, nums2){// Replace this placeholder return statement with your codereturn [];}export {nextGreaterElement}
Click "Run" to evaluate your code.
Next Greater Element I