class Solution {
public:
/**
* @param prices: Given an integer array
* @return: Maximum profit
*/
int maxProfit(vector<int> &prices) {
// write your code here
int i,j;
if(prices.size()==0)
return 0;
int min=prices[0],max=0,b=0;
for(i=1;i<prices.size();i++)
{
if(prices[i]<min)
min=prices[i];
b=prices[i]-min;
if(b>max)
max=b;
}
return max;
}
};