you give array price pricesi price give stock ith dayYou want maximize profit choose single day buy stock choose different day future sell stockreturn maximum profit achieve transaction if achieve profit return 0 example 1input price 715364output 5explanation Buy day 2 price 1 sell day 5 price 6 profit 61 5note buying day 2 selling day 1 allow buy sellExample 2input price 76431output 0explanation in case transaction max profit 0 Constraints1 priceslength 1050 pricesi 104