/*
@Copyright:LintCode
@Author: Monster__li
@Problem: http://www.lintcode.com/problem/best-time-to-buy-and-sell-stock
@Language: Java
@Datetime: 17-03-02 12:15
*/
public class Solution {
/**
* @param prices: Given an integer array
* @return: Maximum profit
*/
public int maxProfit(int[] prices) {
// write your code here
int maxProfit=0,i,j;
for(i=0;i<prices.length-1;i++)
{
for(j=i+1;j<prices.length;j++)
{
if(prices[j]-prices[i]>maxProfit)
{
maxProfit=prices[j]-prices[i];
}
}
}
return maxProfit;
}
}