make my life better

  • languages

algo/algorithms 2

206. Reverse Linked List

206. Reverse Linked List  Given the head of a singly linked list, reverse the list, and return the reversed list. Example 1: Input: head = [1,2,3,4,5]Output: [5,4,3,2,1]Example 2: Input: head = [1,2]Output: [2,1]Example 3:Input: head = []Output: [] Constraints:The number of nodes in the list is the range [0, 5000].-5000  class Solution: def reverseList(self, head: Optional[ListNode]) -> Optio..

algo/algorithms 2025.03.03

카데인(kadane) 알고리즘

카데인 알고리즘카데인 알고리즘이란, Dynamic Programming 을 활용해 시간복잡도 O(N)으로 배열의 최대 부분합을 구해는 알고리즘이다.N번째 원소를 갖는 부분배열의 최댓값을 N-1번째 원소를 갖는 부분배열의 최댓값을 이용해 구하는 방식이다. N-1번째 원소를 갖는 부분배열의 최댓값을 안다고 가정했을 때, N번째 원소를 갖는 부분배열의 최댓값은 아래와 같이 결정될 수 있다. N-1번째 원소를 갖는 부분배열에 포함될 수도 있고, 아니면 원소 하나로 구성된 부분배열이 만들어질 수 있다는 의미와 같다.  코드def kadane_algorithm(arr): prev_max=arr[0] res_max=arr[0] for i in range(1, len(arr)): pre..

algo/algorithms 2025.02.25
이전
1
다음
더보기
프로필사진

make my life better

  • 분류 전체보기 (27)
    • languages (0)
      • kotlin (0)
      • python (0)
    • algo (26)
      • leetcode (24)
      • algorithms (2)
    • system design (1)
    • book (0)
      • 가상 면접 사례로 배우는 대규모 시스템 설계 기초.. (0)
    • database (0)

Tag

leetcode, System Design,

최근글과 인기글

  • 최근글
  • 인기글

최근댓글

공지사항

페이스북 트위터 플러그인

  • Facebook
  • Twitter

Archives

Calendar

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

티스토리툴바