Implement a class StockCalc, which contains a method getProfit. This method
takes an int[] representing the stock price for a given stock on a sequence of
days, and returns, as an int, the maximum profit that can be reaped by buying
on one of those days and selling on a later day.
Here is the method signature:
public int getProfit(int[] prices);
prices is an int[]. Each Integer must be greater than 0 and less than 1000.
There must be at least 1 element in the int[] and at most 100 elements.
Note:
-If no profit can be made, return 0.
Examples:
-prices={3,5,10,20,80,70,40,1}, returns 77
-prices={80,70,40,3,2,1}, returns 0 |