How can I optimize this solution?


  • 0
    T
        int maxProfix = 0,point = 0;
        for (int i = 0; i < prices.length; i++) {
        	if (prices[point] < prices[i] && prices[i] - prices[point] > maxProfix)
                maxProfix = prices[i] - prices[point];
    		if (prices[point] > prices[i])point = i;		
    	}
        return maxProfix;

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.