Find the Next Greatest Element
You have implemented a 'huge' data structure to solve the problem. In this case though, the solution is to use a relatively simple case of memoization. If you work backward from the end of the array, you can use what you have already learned for previous values.....

... in essence, you can use the subsequent NGE's to bootstrap your way to calculate the current cell's NGE.

private static int[] computeNGE(int[] tocompute) {
    if (tocompute == null) {
        throw new NullPointerException();
    }
    if (tocompute.length == 0) {
        return new int[0];
    }
    if (tocompute.length == 1) {
        return new int[]{-1};
    }
    int[] indices = new int[tocompute.length];
    int[] nge = new int[tocompute.length];
    nge[tocompute.length - 1] = -1;
    indices[tocompute.length - 1] = -1;
    for (int i = tocompute.length - 2; i &gt;= 0; i--) {
        int j = i + 1;
        while (j != -1 &amp;&amp; tocompute[j] &lt;= tocompute[i]) {
            j = indices[j];
        }
        indices[i] = j;
        nge[i] = j == -1 ? -1 : tocompute[j];
    }
    return nge;
}


The above solution will have close to an \$O(n)\$ time complexity, because, the worst case is a 2-times iteration through the data.