...

/

Challenge 7: Next Greater Element using Stack

Challenge 7: Next Greater Element using Stack

Try to solve the Next Greater Element Using a Stack problem.

Statement

Implement a nextGreaterElement() function that takes an array of integers, arr, as input and returns the next greater number for every element in the array.

The next greater number for a number arr[i] is the first number to its right that is greater than arr[i]. If no such number exists, return -1 for this number.

Constraints:

  • 11 \leq
...