maintain the "max_profit" and "min_price".
public class Solution {
public int max_profit(int[] prices) {
int min_price = Integer.MAX_VALUE;
int max_pro = 0;
for (int i=0; i<prices.length; i++) {
min_price = Math.min(min_price, prices[i]);
max_pro = Math.max(max_pro, prices[i]-min_price);
}
return max_pro;
}
}