일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- Class
- Regular Expression
- 109. Convert Sorted List to Binary Search Tree
- 43. Multiply Strings
- 운영체제
- t1
- kaggle
- 컴퓨터의 구조
- Generator
- DWG
- Convert Sorted List to Binary Search Tree
- concurrency
- iterator
- LeetCode
- 30. Substring with Concatenation of All Words
- 315. Count of Smaller Numbers After Self
- 프로그래머스
- Python Implementation
- data science
- Python
- attribute
- Python Code
- shiba
- Decorator
- Protocol
- 파이썬
- 715. Range Module
- Substring with Concatenation of All Words
- 밴픽
- 시바견
Archives
- Today
- Total
목록Count of Smaller Numbers After Self (1)
Scribbling
LeetCode: 315. Count of Smaller Numbers After Self
Several solutions and short analysis of each one. 1. List + Binary Search The most straightforward solution, however, time complexity is O(N**2). class Solution: def countSmaller(self, nums: List[int]) -> List[int]: from bisect import insort, bisect_left arr = [] count = [] for i in range(len(nums) - 1, -1, -1): num = nums[i] idx = bisect_left(arr, num) count.append(idx) insort(arr, num) return ..
Computer Science/Coding Test
2022. 2. 10. 11:22