FastPrepParameterized Divisibility Labels
Problems/Parameterized Divisibility Labels

Parameterized Divisibility Labels

Deloitte logoDeloitte● EasyNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Deloitte new grad online assessment. The report gives the parameters, a loop over a range, and the idea of labels A, B, and AB for divisibility. Its short pseudocode leaves out the equality tests, the output when nothing matches, and that the branches exclude each other. We state those rules clearly. Our version is about 88% the same as the reported question.

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 = 2b = 3n = 7return = ["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 = 1b = 2n = 4return = ["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

More Deloitte Online Assessment questions

  • Seventh Nearest PalindromeOA · Seen May 2026
  • Minimum Deletions for a Non-PalindromeOA · Seen Jul 2025
  • Minimum-Cost Solar Rooftop AllocationOA · Seen Jul 2025
  • Pair Elements with Even SumsOA · Seen Jul 2025
  • Count Divisible PermutationsOA · Seen Jan 2025
  • Largest Element in an ArrayOA · Seen Nov 2024
  • Install Carbon FiltersOA · Seen Oct 2023
  • Longest Substring with Even OccurrencesOA · Seen Oct 2023
  • Maximum Sum RectangleOA · Seen Apr 2022
  • Annual Bank Balance with Monthly Card FeesOA · Seen Jan 2022

Similar questions at other companies

  • Basic Item DiscountsPalantir · OAPalantir interview questions
  • Diagonal Bounce TraversalAutodesk · OAAutodesk interview questions
  • Costliest ChocolateRippling · OARippling interview questions
  • Online No-Intercept Linear RegressionTwo Sigma · OATwo Sigma interview questions
  • Plus Mult ArrayIBM · OAIBM interview questions
  • Progressive Tax CalculatorInteractive Brokers · OA
  • 2020 Account Balance with Monthly Card FeesDRW · OADRW interview questions
  • Array Challenge (QR Intern)Akuna Capital · OAAkuna Capital interview questions
  • Latency Bucket CounterDatadog · OA · PHONE SCREENDatadog interview questions
  • First Fibonacci Number at Least the Array SumBitGo · OABitGo interview questions

Interview reports that mention this question

  • Deloitte New Grad Tech OA and Interview Questions: 14 Experiences
All Deloitte interview questionsSee Deloitte hiring insights
Saved
class Solution {
    public String[] divisibilityLabels(int a, int b, int n) {
        // Write your solution here.
    }
}
Checking account…