买卖股票的最佳时机
public class Solution {
/**
* @param prices: Given an integer array
* @return: Maximum profit
*/
public int maxProfit(int[] prices) {
// write your code here
int max_pro = 0;
int temp;
for (int m = 0; m < prices.length-1; m++) {
for (int n = m + 1; n <prices.length; n++) {
if (prices[m] > prices[n])
continue;
else
temp = prices[n] - prices[m];
if(max_pro<temp)
max_pro = temp;
}
}
return max_pro;
}
}