You are given an array of digits called digits. Your task is to determine the number of distinct three-digit even numbers that can be formed using these digits.
Note: Each copy of a digit can only be used once per number, and there may not be leading zeros.
funchelper(freq map[int]int, at int)int { res := 0 for k, v := range freq { if at == 2 { if k%2 == 1 { continue } freq[k]-- res += helper(freq, at-1) freq[k]++ } if at == 1 { if v == 0 { continue } freq[k]-- res += helper(freq, at-1) freq[k]++ } if at == 0 { if v == 0 || k == 0 { continue } res++ } } return res }
functotalNumbers(digits []int)int { freq := make(map[int]int) for _, d := range digits { freq[d]++ } return helper(freq, 2) }