The stocks problem - find the biggest profit that can be made
This implementation is very inefficient due to creating a lot of arrays. Even worse is that the arrays are of type Integer[] instead of int[] which would be lighter.

A much simpler algorithm is possible:


iterate over the prices
keep track of the max difference seen so far, and the local minimum and maximum
if the current price is bigger than the local max


update the local max
if the difference from the local minimum is bigger than the max difference seen so far, then update the max difference = the best time to sell so far

if the current price is less than the local minimum then reset the local min and max
the maximum profit is the maximum difference at the end of the iteration


It's nice that you added some test cases, but it would be a lot better to turn those into proper junit test cases.

You missed some interesting corner cases:


decreasing sequence, for example: 5, 1
degenerate input: empty array or single element


Negative values as stock prices in the test cases seem strange and a bit confusing.

"stocks" is a poor name for a function that returns an integer. Plural names imply some sort of collection. The number returned is the maximum profit you can make. So for example calculateMaxProfits would be more appropriate.

Suggested implementation

Applying the suggestions above,
here's a solution that's \$O(n)\$ time and \$O(1)\$ space.

public int maxProfit(int[] prices) {
    if (prices.length &lt; 1) {
        return 0;
    }

    int maxDiff = 0;
    int localMin = prices[0];
    int localMax = localMin;

    for (int price : prices) {
        if (price &gt; localMax) {
            localMax = price;
            int localDiff = localMax - localMin;
            if (localDiff &gt; maxDiff) {
                maxDiff = localDiff;
            }
        } else if (price &lt; localMin) {
            localMin = localMax = price;
        }
    }

    return maxDiff;
}