Solved MaxProfit in C