Count Multiples of Three with Two Sevens
Reported by candidates from Hudson River Trading's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Hudson River Trading reported this one in October 2026, and the surprise is how little machinery it needs. The data structure the solution hinges on is just the array itself, plus a single integer counter. No hash map, no sorting, no fancy tricks. If you have the OA in a day or two, don't overthink it. You scan once, test two conditions per value, and return the tally. The only real risk is a sloppy digit count or a missed edge. If your head goes blank under the timer, StealthCoder is the invisible safety net running during the live assessment.
The problem
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.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick is that there's no trick. For each number, check n % 3 == 0, then count the 7s in its decimal digits. Peel digits with n % 10 and n / 10 in a loop, or convert to a string and count the character '7'. Either way each value has at most 10 digits, so the work is O(n * 10), which is effectively linear for 10^5 elements. The common pitfall is counting digits wrong, like stopping at the first 7 instead of requiring at least two, or checking the sum of digits incorrectly. Check example 1 by hand: 77 isn't divisible by 3, 707 isn't either, so only 177 and 777 count. Values go up to 10^9, which fits in a standard 32-bit signed int, but use a long if you're nervous. If you blank mid-assessment, StealthCoder can hand you this loop in seconds.
The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.
You can drill Count Multiples of Three with Two Sevens cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Hudson River Trading's OA.
Hudson River Trading reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Count Multiples of Three with Two Sevens FAQ
How hard is the Hudson River Trading double-seven problem really?+
Easy. It's a single pass with two simple checks per element. The difficulty is in reading carefully, not in the algorithm. Most of the risk is off-by-one logic on the digit count, so test against the three given examples before submitting.
What's the trick to counting multiples of three with two sevens?+
There isn't a hidden one. Check divisibility by 3 using the modulo operator, then count how many digits equal 7. If the count is 2 or more, increment your answer. Do both checks for every number and return the total.
Should I use string conversion or digit extraction?+
Either works. Digit extraction with n % 10 and n / 10 avoids allocating strings and is clean in any language. String conversion is shorter to write. With 10^5 numbers of at most 10 digits, performance is fine both ways, so pick the one you won't bug.
What edge cases should I test before submitting?+
Test a number with exactly one 7 that's divisible by 3, like 27 in example 1, and a number with two 7s that isn't, like 77. Also test the upper bound of 10^9 and a single-element array. The values are all positive, so zero and negatives aren't a concern.
How do I prepare for this in 48 hours?+
Write the solution once from scratch in your chosen language and run it on the three examples. Then rehearse similar digit-based filters, like counting digits or checking digit sums. This pattern is a basic scan with a predicate, so an hour of practice is plenty.