class Solution {

public:

    /**

     * @param prices: Given an integer array

     * @return: Maximum profit

     */

    int maxProfit(vector<int> &prices) {

        // write your code here

        if(prices.empty())

        return 0 ;

        int maxpro = 0,minpro = prices[0];

        for(int i = 1 ; i < prices.size() ; i++ )

        {

            if(prices[i] < minpro)

            minpro = prices[i];

            int fall = prices[i] - minpro ;

            if(fall > maxpro)

            maxpro = fall;

        }

        return maxpro;

    }

};