티스토리 뷰
728x90
class Solution {
public int maxProfit(int[] prices) {
int buy = Integer.MIN_VALUE;
int cooldown = 0;
int sell = 0;
for (int p : prices) {
buy = Math.max(buy, cooldown - p);
cooldown = Math.max(cooldown, sell);
sell = Math.max(sell, buy + p);
}
return sell;
}
}
https://gonewbie.github.io/2020/02/26/daily-algorithm-best-time-to-buy-and-sell-stock/
daily-algorithm-best-time-to-buy-and-sell-stock · gonewbie's Studio
동적 프로그래밍 알고리즘 해결에 있어서 문제를 해결하는 가장 기본적인 방법은 분할 정복(Divide & Conquer)이다. 즉, 커다란 문제를 여러 개의 작은 문제로 나누어 처리하는 것이다. 프로그래밍
gonewbie.github.io
https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-cooldown/
Best Time to Buy and Sell Stock with Cooldown - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com
728x90
'공부' 카테고리의 다른 글
[spark] RDD, DataFrame (0) | 2022.09.03 |
---|---|
[spark] lazy evalution (1) | 2022.09.03 |
[github] Why am I still getting "You've used 100% of included services for GitHub Storage (GitHub Actions and Packages)" after deleting all Artifacts? (0) | 2022.08.31 |
[docker] Dockerfile (sh file) (0) | 2022.08.31 |
[aws] emr create-cluster --configurations file:// (0) | 2022.08.31 |
댓글
250x250
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- 테슬라 추천
- 할인
- 메디파크 내과 전문의 의학박사 김영수
- 테슬라
- 개리마커스
- Kluge
- 테슬라 리퍼럴 코드 생성
- 인스타그램
- 모델y
- 레퍼럴
- wlw
- 어떻게 능력을 보여줄 것인가?
- 팔로워 수 세기
- 김달
- 테슬라 리퍼럴 코드 혜택
- 테슬라 레퍼럴
- Bot
- 모델 Y 레퍼럴
- 테슬라 크레딧 사용
- 유투브
- 연애학개론
- 책그림
- follower
- 클루지
- 테슬라 레퍼럴 적용 확인
- 테슬라 리퍼럴 코드
- 테슬라 레퍼럴 코드 확인
- COUNT
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함