Parameterized Divisibility Labels
Updated
Problem statement
You are given positive integers a, b, and n. For each integer i from 0 through n - 1, produce exactly one string:
"AB"ifiis divisible by bothaandb."A"ifiis divisible byaonly."B"ifiis divisible bybonly.- The decimal representation of
iotherwise.
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^91 <= 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