2148. Count Elements With Strictly Smaller and Greater Elements Easy
1/**
2 * [2148] Count Elements With Strictly Smaller and Greater Elements
3 *
4 * Given an integer array nums, return the number of elements that have both a strictly smaller and a strictly greater element appear in nums.
5 *
6 * Example 1:
7 *
8 * Input: nums = [11,7,2,15]
9 * Output: 2
10 * Explanation: The element 7 has the element 2 strictly smaller than it and the element 11 strictly greater than it.
11 * Element 11 has element 7 strictly smaller than it and element 15 strictly greater than it.
12 * In total there are 2 elements having both a strictly smaller and a strictly greater element appear in nums.
13 *
14 * Example 2:
15 *
16 * Input: nums = [-3,3,3,90]
17 * Output: 2
18 * Explanation: The element 3 has the element -3 strictly smaller than it and the element 90 strictly greater than it.
19 * Since there are two elements with the value 3, in total there are 2 elements having both a strictly smaller and a strictly greater element appear in nums.
20 *
21 *
22 * Constraints:
23 *
24 * 1 <= nums.length <= 100
25 * -10^5 <= nums[i] <= 10^5
26 *
27 */
28pub struct Solution {}
29
30// problem: https://leetcode.com/problems/count-elements-with-strictly-smaller-and-greater-elements/
31// discuss: https://leetcode.com/problems/count-elements-with-strictly-smaller-and-greater-elements/discuss/?currentPage=1&orderBy=most_votes&query=
32
33// submission codes start here
34
35impl Solution {
36 pub fn count_elements(nums: Vec<i32>) -> i32 {
37 0
38 }
39}
40
41// submission codes end
42
43#[cfg(test)]
44mod tests {
45 use super::*;
46
47 #[test]
48 fn test_2148() {
49 }
50}
51
Back
© 2025 bowen.ge All Rights Reserved.