HackerRank: Equal Stacks
Method decomposition

The main method reads and parses the input,
and does a large part of the calculation logic too.
It would be better to move the calculation outside.
That is, after the input is read and parsed,
it will be better to leave just this in main:

System.out.println(findEqualHeight(h1, h2, h3));


And all the calculation logic can be in findEqualHeight.

Simplify the algorithm

The algorithm is a bit complicated and hard to understand.
It's also inefficient.
As you knock off cylinders from the 3rd stack,
you check if you can reduce the others from the top.
This can lead to recalculating the sums multiple times.

Consider this alternative implementation:
knock off cylinders from the highest stack,
until they are all of the same height:

static int findEqualHeight(int[] h1, int[] h2, int[] h3) {
    int sum1 = sum(h1);
    int sum2 = sum(h2);
    int sum3 = sum(h3);

    int i1 = 0;
    int i2 = 0;
    int i3 = 0;

    while (true) {
        if (sum1 &gt; sum2 || sum1 &gt; sum3) {
            sum1 -= h1[i1++];
        } else if (sum2 &gt; sum1 || sum2 &gt; sum3) {
            sum2 -= h2[i2++];
        } else if (sum3 &gt; sum1 || sum3 &gt; sum2) {
            sum3 -= h3[i3++];
        } else {
            break;
        }
    }

    return sum1;
}

static int sum(int[] arr) {
    return IntStream.of(arr).sum();
}