ProblemSolving2 leetcode 121 - Best Time to Buy and Sell Stock 하루에 한번 매매를 할 수 있을 때, 어떻게 하면 저점에 사서, 고점에 팔 수 있는 알고리즘을 짜는 것이다. for loop를 두번 도는 것이 아닌, 매 loop를 돌 때마다 최고 가격과 최저가격을 기록하면 되는 것이므로, 아래와 같이 그냥 O(n)으로도 풀이가 가능하다. class Solution(object): def maxProfit(self, prices): """ :type prices: List[int] :rtype: int """ import sys profit = 0 min_price = sys.maxsize for price in prices: if price profit : profit = .. 2022. 3. 25. 페이스북 tech lead가 추천하는 leetcode 문제 75 New Year Gift to every fellow time-constrained engineer out there looking for a job, here's a list of the best LeetCode questions that teach you core concepts and techniques for each category/type of problems! Many other LeetCode questions are a mash of the techniques from these individual questions. I used this list in my last job hunt to only do the important questions. Good luck and Happy New.. 2022. 3. 25. 이전 1 다음