JAVA_LeetCode 309_Best Time to Buy and Sell Stock with Cooldown 풀이 class Solution { public int maxProfit(int[] prices) { if(prices == null || prices.length == 0) return 0; int n = prices.length; int[] buy = new int[n]; // i일 차에 주식을 산 상태에서의 최대 이익 int[] sell = new int[n]; // i일 차에 주식을 판 상태에서의 최대 이익 int[] cooldown = new int[n]; // i일 차에 쿨다운 상태의 최대 이익 buy[0] = -prices[0]; // 첫날 산 경우 sell[0] = 0; // 첫날 팔 수 없음 cooldown[0] = 0; // 첫날 쿨다운 임의로 0 for(int i = 1; i < n; i++){ // buy 상태: 두 가지 경우 중 최대 // 1. 이...