class Solution {
public:
int maxProfit(vector<int>& prices) {
if(prices.size() <=0){
return 0;
}
int dp = 0;
int minP = 0;
minP = prices[0];
for (int i = 1; i < prices.size(); i++)
{
dp = max(dp , prices[i] - minP);
if(prices[i] < minP){
minP = prices[i];
}
}
return dp;
}
};