로딩
요청 처리 중입니다...

[Python] LeetCode 121 : Best Time to Buy and Sell Stock - level Easy

 [Python] LeetCode 121 : Best Time to Buy and Sell Stock  - level Easy

[Python] LeetCode : Best Time to Buy and Sell Stock Array 문제 링크 https://leetcode.com/problems/best-time-to-buy-and-sell-stock/ 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 해결 시점은 오늘이다.

가장 낮은 가격으로 샀던 날보다 오늘이 싸다면 산다. (if prices[i] < lm: lm = prices[i]) 따라서 오늘 살 수도 있고 안 살 수도 있다.

(=오늘이 가장 저렴할 수도, 다른 날이 저렴했을 수도 있다) 오늘 팔아서 얻는 이익이 가장 크다면 판다. (if prices[i] - lm > m: prices[i] - lm) # code class ...