Fizz Buzz
Updated
Problem statement
Given an integer n, return a list of n strings for the numbers 1, 2, ..., n, in that order. The item for number i is:
"FizzBuzz"ifican be divided by both 3 and 5."Fizz"ifican be divided by 3 but not by 5."Buzz"ifican be divided by 5 but not by 3.- The number
iitself, written as text (for example"7"), in every other case.
The words must be spelled exactly as shown, with capital F and B and no spaces.
Function
fizzBuzz(n: int) → List<String>Examples
Example 1
n = 7return = ["1","2","Fizz","4","Buzz","Fizz","7"]3 and 6 can be divided by 3, so they become "Fizz". 5 can be divided by 5, so it becomes "Buzz". The other numbers stay as they are, written as text.
Example 2
n = 17return = ["1","2","Fizz","4","Buzz","Fizz","7","8","Fizz","Buzz","11","Fizz","13","14","FizzBuzz","16","17"]15 can be divided by both 3 and 5, so it becomes "FizzBuzz". The other multiples of 3 (3, 6, 9, 12) are "Fizz", and the other multiples of 5 (5, 10) are "Buzz". 16 and 17 are not multiples of either, so they stay "16" and "17".
Example 3
n = 12return = ["1","2","Fizz","4","Buzz","Fizz","7","8","Fizz","Buzz","11","Fizz"]The multiples of 3 are 3, 6, 9 and 12, so they become "Fizz". The multiples of 5 are 5 and 10, so they become "Buzz". No number up to 12 is a multiple of both, so there is no "FizzBuzz". The list ends on "Fizz".
Constraints
1 <= n <= 2000
More Bloomberg LP Phone Screen questions
- N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Fewest Coins CombinationPHONE SCREEN · Seen Nov 2026
- Recommend Films from Viewers Who Watched Everything You DidPHONE SCREEN · Seen Nov 2026
- Track New Values in Sorted OrderPHONE SCREEN · Seen Nov 2026
- Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Mutable Stock Price Top KPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Sparse Vector and Matrix OperationsPHONE SCREEN · Seen Oct 2026
- Add Two Numbers IIPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
Similar questions at other companies
- Subtract Two Large Number StringsStackAdapt · PHONE SCREENStackAdapt interview questions
- Fair Coin from a Biased CoinAnthropic · PHONE SCREENAnthropic interview questions
- Fizz and Buzz Words From 1 to nDocuSign · PHONE SCREENDocuSign interview questions
- Double-Base PalindromesxAI · PHONE SCREENxAI interview questions
- Add Signed Character ArraysByteDance · PHONE SCREENByteDance interview questions
- Per-Segment SpeedingOnePay · PHONE SCREENOnePay interview questions
- Add Decimal Strings ExactlyMeta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions
- Format a Centered Pagination BarMixpanel · PHONE SCREENMixpanel interview questions
- Get Max DeletionsJP Morgan Chase · OAJP Morgan Chase interview questions
- Add Two Numeric Strings with CarryZipRecruiter · ONSITE INTERVIEWZipRecruiter interview questions
Bloomberg LP interview experiences
- Bloomberg SWE Phone Screen and Onsite: 1 Experience
- Bloomberg SWE Phone Screens with Two Teams: 1 Experience
- Bloomberg AI Interview, Hiring Level Not Reported: 2 Experiences
- Bloomberg Experienced SWE AI Coding Interviews: 2 Experiences
- Bloomberg New Grad AI-Assisted Coding Rounds: 3 Experiences
- Bloomberg New Grad SWE AI-Assisted Coding Rounds: 1 Experience