Maximum Profit Hackerrank Solution