2455. Average Value of Even Numbers That Are Divisible by Three Easy

@problem@discussion
#Array#Math



1/**
2 * [2455] Average Value of Even Numbers That Are Divisible by Three
3 *
4 * Given an integer array nums of positive integers, return the average value of all even integers that are divisible by 3.
5 * Note that the average of n elements is the sum of the n elements divided by n and rounded down to the nearest integer.
6 *  
7 * <strong class="example">Example 1:
8 * 
9 * Input: nums = [1,3,6,10,12,15]
10 * Output: 9
11 * Explanation: 6 and 12 are even numbers that are divisible by 3. (6 + 12) / 2 = 9.
12 * 
13 * <strong class="example">Example 2:
14 * 
15 * Input: nums = [1,2,4,7,10]
16 * Output: 0
17 * Explanation: There is no single number that satisfies the requirement, so return 0.
18 * 
19 *  
20 * Constraints:
21 * 
22 * 	1 <= nums.length <= 1000
23 * 	1 <= nums[i] <= 1000
24 * 
25 */
26pub struct Solution {}
27
28// problem: https://leetcode.com/problems/average-value-of-even-numbers-that-are-divisible-by-three/
29// discuss: https://leetcode.com/problems/average-value-of-even-numbers-that-are-divisible-by-three/discuss/?currentPage=1&orderBy=most_votes&query=
30
31// submission codes start here
32
33impl Solution {
34    pub fn average_value(nums: Vec<i32>) -> i32 {
35        0
36    }
37}
38
39// submission codes end
40
41#[cfg(test)]
42mod tests {
43    use super::*;
44
45    #[test]
46    fn test_2455() {
47    }
48}
49


Back
© 2025 bowen.ge All Rights Reserved.