you give integer array price pricesi price give stock ith dayOn day decide buy andor sell stock you hold share stock time however buy immediately sell dayfind return maximum profit achieve Example 1input price 715364output 7explanation Buy day 2 price 1 sell day 3 price 5 profit 51 4Then buy day 4 price 3 sell day 5 price 6 profit 63 3total profit 4 3 7example 2input price 12345output 4explanation Buy day 1 price 1 sell day 5 price 5 profit 51 4total profit 4example 3input price 76431output 0explanation there way positive profit buy stock achieve maximum profit 0 Constraints1 priceslength 3 1040 pricesi 104