FizzBuzz With Bubble and Scream
Updated
Problem statement
Given an integer n, go through the numbers from 1 to n in order and turn each number i into one string:
"Bubble Scream"ifiis divisible by both3and5;"Bubble"ifiis divisible by3but not by5;"Scream"ifiis divisible by5but not by3;- otherwise,
iitself written in decimal, for example"7".
Return the n strings as a list, in order from 1 to n.
The two words in "Bubble Scream" are separated by a single space, and every word starts with a capital letter.
Function
bubbleScream(n: int) → List<String>Examples
Example 1
n = 15return = ["1","2","Bubble","4","Scream","Bubble","7","8","Bubble","Scream","11","Bubble","13","14","Bubble Scream"]3, 6, 9 and 12 are divisible by 3 but not by 5, so they become "Bubble". 5 and 10 are divisible by 5 but not by 3, so they become "Scream". 15 is divisible by both 3 and 5, so it becomes "Bubble Scream". The other eight numbers are written as themselves.
Example 2
n = 5return = ["1","2","Bubble","4","Scream"]3 becomes "Bubble" and 5 becomes "Scream". No number up to 5 is divisible by both 3 and 5, so "Bubble Scream" does not appear.
Example 3
n = 1return = ["1"]1 is not divisible by 3 or by 5, so the list holds just "1".
Constraints
1 <= n <= 1000
More Zillow Phone Screen questions
- Valid ParenthesesPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2025
- Time Based Key-Value StorePHONE SCREEN · Seen Feb 2024
- Filter Formatted Records by CriteriaPHONE SCREEN · Seen Sep 2023
- Build a Hash TablePHONE SCREEN · ONSITE INTERVIEW · Seen Feb 2023
- Jump GamePHONE SCREEN · Seen Dec 2022
- Reversible Run-Length EncodingPHONE SCREEN · Seen Nov 2022
- Spiral MatrixPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2022
- Two Sum: All PairsPHONE SCREEN · Seen Nov 2022
- Employee Free TimePHONE SCREEN · Seen Oct 2022
- First Unique Character in a StringPHONE SCREEN · Seen Oct 2022
Similar questions at other companies
- Subtract Two Large Number StringsStackAdapt · PHONE SCREENStackAdapt interview questions
- Fair Coin from a Biased CoinAnthropic · PHONE SCREENAnthropic interview questions
- Add Two Integers Given as StringsJane Street · PHONE SCREENJane Street interview questions
- Fizz and Buzz Words From 1 to nDocuSign · PHONE SCREENDocuSign interview questions
- Fizz BuzzBloomberg LP · PHONE SCREENBloomberg LP 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