일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 파이썬
- data science
- 109. Convert Sorted List to Binary Search Tree
- Python Implementation
- attribute
- 컴퓨터의 구조
- concurrency
- Substring with Concatenation of All Words
- iterator
- Decorator
- 43. Multiply Strings
- 315. Count of Smaller Numbers After Self
- Regular Expression
- 시바견
- shiba
- DWG
- 밴픽
- LeetCode
- Generator
- 715. Range Module
- Python
- Python Code
- 30. Substring with Concatenation of All Words
- 프로그래머스
- 운영체제
- Class
- Protocol
- Convert Sorted List to Binary Search Tree
- t1
- kaggle
Archives
- Today
- Total
목록Kth Largest Element in an Array (1)
Scribbling
LeetCode: 215. Kth Largest Element in an Array
O(N*logK) Time Complexity Solution using heap. class Solution: def findKthLargest(self, nums: List[int], k: int) -> int: import heapq h = [] for num in nums: if len(h) < k: heapq.heappush(h, num) else: heapq.heappush(h, num) heapq.heappop(h) return h[0] A better approach is to quick selection, runs within O(N) time on average. But this runs with O(N) memory. import random class Solution: def fin..
Computer Science/Coding Test
2021. 12. 11. 11:26