Grind75
문제로
1
2
3
4
5
6
7
8
9
10
11
12
| class Solution {
public int maxProfit(int[] prices) {
int min = Integer.MAX_VALUE;
int profit = 0;
for(int price : prices) {
if(min > price) min = price;
if(price - min > profit) profit = price - min;
}
return profit;
}
}
|

이 문제는 Grind 169에서도 다뤘다: Grind 169 - Best Time to Buy and Sell Stock