Sandbox

  • 홈
  • 태그
  • 방명록

Merge Sort 2

[Coderust] Sort a Linked List Using Merge Sort

Problem Solution # Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def sortList(self, head: Optional[ListNode]) -> Optional[ListNode]: if not head or not head.next: return head # find the middle of the linked list # https://leetcode.com/problems/middle-of-the-linked-list/ slow = head fast = head.next..

CODE/Algorithms & Data Structures 2022.05.22

[LeetCode] Merge k Sorted Lists

Problem Solution My initial approach was to compare the head nodes from each list, put the smallest onto the result linked list, and proceed the pointer that was on the smallest node. The time complexity for this approach would be O(kN) where k is the number of elements in lists and N is the number of nodes in the final linked list. I did not find a clean way to implement this. Solution using me..

CODE/Algorithms & Data Structures 2021.10.18
이전
1
다음
더보기
프로필사진

Sandbox

  • 분류 전체보기 (48)
    • CODE (2)
      • Algorithms & Data Structure.. (43)
      • React (0)
    • READ (3)

Tag

hackerrank, depth first search, java, python3, Merge Sort, Coderust, inorder traversal, algorithm, Implementation, preorder traversal, LinkedList, binary search tree, array, level order traversal, string, Binary Search, LeetCode, Linked List, dynamic programming, Binary Tree,

최근글과 인기글

  • 최근글
  • 인기글

최근댓글

공지사항

페이스북 트위터 플러그인

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

티스토리툴바