```
// eg. [20,10, 15, 5, 12, 15, 10]
if(prices.length < 1 ) return 0;
int min = prices[0]; int diff = 0; int max = 0;
for(int i = 1; i < prices.length; i++){
if(prices[i] < min) min = prices[i];
diff = prices[i] - min;
if(max < diff) max = diff;
}
return max;
```