Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | |||||
| 3 | 4 | 5 | 6 | 7 | 8 | 9 |
| 10 | 11 | 12 | 13 | 14 | 15 | 16 |
| 17 | 18 | 19 | 20 | 21 | 22 | 23 |
| 24 | 25 | 26 | 27 | 28 | 29 | 30 |
| 31 |
Tags
- 문자열
- greedy
- Java
- binary search
- 코테
- 프로그래머스
- 러닝일지
- BFS
- 알고리즘
- SQL
- 코딩테스트
- 시뮬레이션
- 문제해결
- 건강
- 운동기록
- COS PRO
- 이분탐색
- 투포인터
- oracle
- 백준
- DP
- MySQL
- db
- math
- dfs
- 문제풀이
- SWEA
- 자바
- BOJ
- priorityqueue
Archives
- Today
- Total
슈콩
COS PRO 1급 JAVA 주식으로 최대 수익을 내세요 본문



[소스 코드]
class Main{
int solution(int[] prices){
[[(guide-anchor):(한줄을 수정해주세요)]]
int inf = 1000000001;
int tmp = inf;
int answer = -inf;
for(int price : prices){
if(tmp != inf)
answer = Math.max(answer, price - tmp);
tmp = Math.min(tmp, price);
}
return answer;
}
}