Count Multiples of Three with Two Sevens
Problem statement
You are given an integer array numbers.
Count how many values satisfy both of these conditions:
- The value is divisible by
3. - Its ordinary base-10 representation contains the digit
7at least twice.
Return that count.
Function
countDoubleSevenMultiples(numbers: int[]) → intExamples
Example 1
numbers = [77,177,707,777,27,3]return = 2177 and 777 are divisible by 3 and contain at least two sevens. The other values fail one or both conditions.
Example 2
numbers = [7,72,717,1770,7770]return = 3The qualifying values are 717, 1770, and 7770.
Example 3
numbers = [111,222,333]return = 0Every value is divisible by 3, but none contains the digit 7.
Constraints
1 <= numbers.length <= 10^5.1 <= numbers[i] <= 10^9.