일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- 715. Range Module
- Python
- 운영체제
- Regular Expression
- Substring with Concatenation of All Words
- 315. Count of Smaller Numbers After Self
- 파이썬
- 30. Substring with Concatenation of All Words
- 시바견
- attribute
- kaggle
- Python Implementation
- t1
- Generator
- 밴픽
- Decorator
- concurrency
- LeetCode
- 43. Multiply Strings
- data science
- 컴퓨터의 구조
- iterator
- Class
- Python Code
- Protocol
- shiba
- 프로그래머스
- DWG
- Convert Sorted List to Binary Search Tree
- 109. Convert Sorted List to Binary Search Tree
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