Is something wrong with the test case?

public int maxProfit(int[] prices) { if (prices.length <= 1) return 0; int profit = 0; int min = prices[0]; for (int i = 0; i < prices.length; i++) { min = Math.min(min, prices[i]); profit = Math.max(profit, prices[i]  min); } return profit; }
buy the stock at 1 (prices[1]) and sell it at 7 (prices[4]). so the profit would be 6 instead of 5