철학과 함께하는 투자인사이트

  • 홈
  • 태그
  • 방명록

algorithm 2

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 = ..

Algorithm/기본 알고리즘 2022.03.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..

Algorithm 2022.03.25
이전
1
다음
더보기
프로필사진

철학과 함께하는 투자인사이트

투자세계와 스토아철학을 좋아합니다. 본업은 개발자 입니다.

  • 블로그
    • 철학
    • 투자
    • 독서
    • Developement
      • Linux tip
      • Toy Project
    • Algorithm
      • 기본 알고리즘
    • k8s
      • know-how
    • 캐슬만병 이야기

Tag

vim-plug, leecode121, 네이버로그인API구현, Ham, 아마추어무선기사, algorithm, ps, computerscience, fastapi, OAuth2.0, 네이버로그인, 121, LeetCode, vim, vimrc, ProblemSolving,

최근글과 인기글

  • 최근글
  • 인기글

최근댓글

공지사항

페이스북 트위터 플러그인

  • Facebook
  • Twitter

Archives

Calendar

«   2025/12   »
일 월 화 수 목 금 토
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

방문자수Total

  • Today :
  • Yesterday :

Copyright © Kakao Corp. All rights reserved.

티스토리툴바