[C++, Java, Python3] Monotonic Stack + Priority Queue
Explanation\n Monotonic stack is used to find the next greater element\n In mid[i] we store all the indexes for who A[i] is next greater element\nFor the input 
**Explanation**\n* Monotonic stack is used to find the next greater element\n* In `mid[i]` we store all the indexes for who `A[i]` is next greater element\nFor the input `[2,4,0,9,6]`, `mid` looks like: `[[], [0], [], [2, 1], []] `. \n\t* `A[1]` is the next greater element for `A[0]`\n\t* `A[3]` is the next greater element for `A[1]` and `A[2]`\n* Iterate over `A` and for each element `A[i]` if there are smaller elements in min heap, poll the elements in the min heap and set `A[i]` as second greater element for them\n* Then push all the elements for who `A[i]` was next greater(elements in `mid[i]`) in to the min heap\n\t* We can now push the elements in `mid[i]` into the min heap because we know one greater element for these elements has already been found. Now we just need to find one more and that will be the second greater element\n\n\n<iframe src="https://leetcode.com/playground/ehacvCUT/shared" frameBorder="0" width="730" height="450"></iframe>\n\n*Time complexity: nlogn*
[]