315. Count of Smaller Numbers After Self Hard

@problem@discussion
#Array#Binary Search#Divide and Conquer#Binary Indexed Tree#Segment Tree#Merge Sort#Ordered Set



1/**
2 * [315] Count of Smaller Numbers After Self
3 *
4 * Given an integer array nums, return an integer array counts where counts[i] is the number of smaller elements to the right of nums[i].
5 *  
6 * Example 1:
7 * 
8 * Input: nums = [5,2,6,1]
9 * Output: [2,1,1,0]
10 * Explanation:
11 * To the right of 5 there are 2 smaller elements (2 and 1).
12 * To the right of 2 there is only 1 smaller element (1).
13 * To the right of 6 there is 1 smaller element (1).
14 * To the right of 1 there is 0 smaller element.
15 * 
16 * Example 2:
17 * 
18 * Input: nums = [-1]
19 * Output: [0]
20 * 
21 * Example 3:
22 * 
23 * Input: nums = [-1,-1]
24 * Output: [0,0]
25 * 
26 *  
27 * Constraints:
28 * 
29 * 	1 <= nums.length <= 10^5
30 * 	-10^4 <= nums[i] <= 10^4
31 * 
32 */
33pub struct Solution {}
34
35// problem: https://leetcode.com/problems/count-of-smaller-numbers-after-self/
36// discuss: https://leetcode.com/problems/count-of-smaller-numbers-after-self/discuss/?currentPage=1&orderBy=most_votes&query=
37
38// submission codes start here
39
40impl Solution {
41    pub fn count_smaller(nums: Vec<i32>) -> Vec<i32> {
42        vec![]
43    }
44}
45
46// submission codes end
47
48#[cfg(test)]
49mod tests {
50    use super::*;
51
52    #[test]
53    fn test_315() {
54    }
55}
56


Back
© 2025 bowen.ge All Rights Reserved.