Reported February 2019
Deloittesimulation

Parameterized Divisibility Labels

Reported by candidates from Deloitte's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Deloitte OA. Under 2s to a working solution.
Founder's read

Deloitte reportedly served this one in February 2019, and it looks like FizzBuzz with the safety rails off. Two parameters, a loop from 0, and labels that sound simple until your first test fails. The catch is the starting point. Zero is divisible by everything, so index 0 always comes back "AB". If you've got an OA coming up, this is a ten-minute problem you can lose by rushing. StealthCoder sits invisibly on your screen as a hedge if you blank mid-assessment, but the logic below is short enough to carry in your head.

The problem

You are given positive integers a, b, and n. For each integer i from 0 through n - 1, produce exactly one string:
"AB" if i is divisible by both a and b.
"A" if i is divisible by a only.
"B" if i is divisible by b only.
The decimal representation of i otherwise.
Return the n produced strings in order.

Function
divisibilityLabels(a: int, b: int, n: int) → String[]

Examples
Example 1
a = 2
b = 3
n = 7
return = ["AB","1","A","B","A","5","AB"]
0 and 6 are divisible by both divisors. The remaining positions follow the single-divisor or decimal rules.
Example 2
a = 1
b = 2
n = 4
return = ["AB","A","AB","A"]
Every number is divisible by 1, and the even positions are also divisible by 2.

Constraints
1 <= a, b <= 10^9
1 <= n <= 100000

Reported by candidates. Source: FastPrep

Pattern and pitfall

The pattern is plain simulation. Loop i from 0 to n-1, check divisibility by both first, then a, then b, else emit the number as a string. Order matters. If you test a before the combined case, "AB" never fires. The edge case that breaks naive solutions is i = 0, since 0 % a == 0 for any positive a. Candidates who copy classic FizzBuzz start at 1 and drop the first element. Also watch a = 1 or b = 1, where everything is divisible, as Example 2 shows. Don't compute the LCM. With a and b up to 10^9 it's unnecessary, and the product can overflow in some languages. Two modulo checks per index is enough. With n capped at 100000 it's O(n) time and O(n) output. If you freeze in the live OA, StealthCoder can surface this loop in seconds, but you should be able to write it cold.

The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.

If this hits your live OA

You can drill Parameterized Divisibility Labels 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 StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Deloitte's OA.

Deloitte 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.

Parameterized Divisibility Labels FAQ

How hard is this Deloitte OA question really?+

Easy. It's FizzBuzz with configurable divisors and a zero-based range. The only real risk is sloppy ordering of the checks or starting at 1. If you handle i = 0 and check the combined case first, you're done.

What's the trick to Parameterized Divisibility Labels?+

Check divisible-by-both before either single case, and start at 0. Since 0 is divisible by every positive integer, the first output is always "AB". Everything else is a straight modulo check with a string conversion fallback.

Do I need the LCM of a and b?+

No. Checking i % a == 0 and i % b == 0 together is equivalent to divisibility by the LCM and avoids overflow worries with values up to 10^9. It's simpler and just as fast for n up to 100000.

Is this FizzBuzz-style simulation still asked?+

Reports show Deloitte used it as of February 2019, and parameterized FizzBuzz variants are a common warm-up format. Expect small twists like custom labels, different ranges, or extra divisors rather than anything algorithmically heavy.

How do I prepare for this in 48 hours?+

Write it once in your language of choice and test a = 1, b = 1, a = b, and n = 1. Confirm the output for index 0 and that numbers convert to strings. Then spend your remaining time on harder problem types.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Deloitte.

OA at Deloitte?
Invisible during screen share
Get it