FastPrepCount Multiples of Three with Two Sevens

Count Multiples of Three with Two Sevens

Hudson River Trading logoHudson River Trading● EasyNEW GRADOA
Learn

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 7 at least twice.

Return that count.

Function

countDoubleSevenMultiples(numbers: int[]) → int

Examples

Example 1

numbers = [77,177,707,777,27,3]return = 2

177 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 = 3

The qualifying values are 717, 1770, and 7770.

Example 3

numbers = [111,222,333]return = 0

Every value is divisible by 3, but none contains the digit 7.

Constraints

  • 1 <= numbers.length <= 10^5.
  • 1 <= numbers[i] <= 10^9.

More Hudson River Trading problems

See Hudson River Trading hiring insights
public int countDoubleSevenMultiples(int[] numbers) {
    // Write your code here.
}
numbers[77,177,707,777,27,3]
expected2
Checking account…