---
# System prepended metadata

title: 2455. Average Value of Even Numbers That Are Divisible by Three
tags: [Leetcode, Easy]

---

# 2455. Average Value of Even Numbers That Are Divisible by Three
###### tags: `Leetcode` `Easy`
Link: https://leetcode.com/problems/average-value-of-even-numbers-that-are-divisible-by-three/
## 思路
## Code
```java=
class Solution {
    public int averageValue(int[] nums) {
        int cnt = 0, sum = 0;
        for(int i=0; i<nums.length; i++){
            if(nums[i]%2==0 && nums[i]%3==0){
                cnt++;
                sum += nums[i];
            }
        }
        return cnt==0?0:(sum/cnt);
    }
}
```