Solved BestTimeToBuyAndSellStock in java