Intuitive approach C++


#1

int Solution::maxProfit(const vector &A) {
int maxp = 0, min = INT_MAX;

for(int i =0;i<A.size();i++)
{
    if(A[i] < min)
    {
        min = A[i];
    }else{
        maxp = max(maxp,A[i] - min);
    }
}

return maxp;

}
`