일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- 315. Count of Smaller Numbers After Self
- Generator
- t1
- Python Code
- 운영체제
- Python Implementation
- Class
- DWG
- 시바견
- Python
- 715. Range Module
- data science
- concurrency
- Decorator
- Protocol
- Substring with Concatenation of All Words
- iterator
- shiba
- Regular Expression
- Convert Sorted List to Binary Search Tree
- 43. Multiply Strings
- 109. Convert Sorted List to Binary Search Tree
- 프로그래머스
- 컴퓨터의 구조
- 밴픽
- attribute
- LeetCode
- 파이썬
- 30. Substring with Concatenation of All Words
- kaggle
Archives
- Today
- Total
목록315. Count of Smaller Numbers After Self (2)
Scribbling
Number of pairs that satisfies the range condition (lower <= p[i] - p[j] <= upper)
How does one can find the number of pairs in an array that satisfies the below condition? : lower
Computer Science/Algorithms & Data Structures
2023. 5. 15. 17:26
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