Create an algorithm to identify what is the next largest element on a stack (using stack/queue operations only) INPUT: [ 10, 3, 1, 14, 15, 5 ] OUTPUT: 10 -> 14 3 -> 14 1 -> 14 14 -> 15 15 -> -1 5 -> -1
Create an algorithm to identify what is the next largest element on a stack (using stack/queue operations only)
INPUT:
[ 10, 3, 1, 14, 15, 5 ]
OUTPUT:
10 -> 14
3 -> 14
1 -> 14
14 -> 15
15 -> -1
5 -> -1