[LeetCode#121] Best Time to Buy and Sell Stock
·
Algorithm/문제풀이
❒ Description제목Best Time to Buy and Sell Stock링크https://leetcode.com/problems/best-time-to-buy-and-sell-stock/description/자료구조선형 자료구조풀 날짜07/24 ❒ Solutionpublic static int maxProfit(int[] prices) { int maxProfit = 0; int minPrice = prices[0]; for (int price : prices) { minPrice = Math.min(minPrice, price); maxProfit = Math.max(maxProfit, price - minPrice); } return..