728x90
반응형
문제
반응형
풀이
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
class Solution {
public int maxProfit(int[] prices) {
int buy = prices[0];
int max = 0;
for(int i : prices) {
if(i - buy > max) {
max = i - buy;
}
if(buy > i) {
buy = i;
}
}
return max;
}
}
|
cs |
728x90
반응형
'[JAVA] LeetCode > Easy' 카테고리의 다른 글
[LeetCode/릿코드] 136. Single Number (0) | 2023.01.24 |
---|---|
[LeetCode/릿코드] 125. Valid Palindrome (0) | 2023.01.24 |
[LeetCode/릿코드] 119. Pascal's Triangle II (0) | 2023.01.24 |
[LeetCode/릿코드] 118. Pascal's Triangle (0) | 2023.01.24 |
[LeetCode/릿코드] 88. Merge Sorted Array (0) | 2023.01.24 |