412. Fizz Buzz
easyAsked at Goldman SachsPrint 'Fizz' for multiples of 3, 'Buzz' for multiples of 5, 'FizzBuzz' for multiples of 15, otherwise the number. Goldman Sachs uses Fizz Buzz as a 5-minute warm-up — they're grading whether your code is clean, not whether you can solve it.
By Alex Chen, Founder, InterviewChamp.AI · Last verified
Source citations
Public interview reports confirming this problem appears in Goldman Sachs loops.
- Glassdoor (2026-Q1)— Goldman Sachs SWE phone-screen reports include Fizz Buzz as a warm-up that confirms you can write any code at all.
- Blind (2025-11)— Goldman Sachs candidate reports list Fizz Buzz among the most common 5-minute opener questions.
Problem
Given an integer n, return a string array answer (1-indexed) where: answer[i] == "FizzBuzz" if i is divisible by 3 and 5; answer[i] == "Fizz" if i is divisible by 3; answer[i] == "Buzz" if i is divisible by 5; answer[i] == i (as a string) otherwise.
Constraints
1 <= n <= 10^4
Examples
Example 1
n = 3["1","2","Fizz"]Example 2
n = 5["1","2","Fizz","4","Buzz"]Example 3
n = 15["1","2","Fizz","4","Buzz","Fizz","7","8","Fizz","Buzz","11","Fizz","13","14","FizzBuzz"]Approaches
1. Modulo with if-else cascade
Test divisibility by 15 first (it implies both 3 and 5), then 3, then 5, otherwise the number.
- Time
- O(n)
- Space
- O(n)
function fizzBuzz(n) {
const result = [];
for (let i = 1; i <= n; i++) {
if (i % 15 === 0) result.push('FizzBuzz');
else if (i % 3 === 0) result.push('Fizz');
else if (i % 5 === 0) result.push('Buzz');
else result.push(String(i));
}
return result;
}Tradeoff: Clean, readable, and the version Goldman wants to see. Check 15 first because 3 and 5 alone would silently take priority and you'd never reach 'FizzBuzz'.
2. String concatenation pattern
Build the result by concatenating 'Fizz' if div3 and 'Buzz' if div5, falling back to the number.
- Time
- O(n)
- Space
- O(n)
function fizzBuzzConcat(n) {
const result = [];
for (let i = 1; i <= n; i++) {
let s = '';
if (i % 3 === 0) s += 'Fizz';
if (i % 5 === 0) s += 'Buzz';
result.push(s || String(i));
}
return result;
}Tradeoff: Avoids the 15-case entirely because Fizz + Buzz IS FizzBuzz. Goldman likes this version because it scales to 'Fizz on 3, Buzz on 5, Bang on 7' without re-checking all pairwise products.
Goldman Sachs-specific tips
Goldman Sachs uses Fizz Buzz as a 'can this candidate code at all' filter — failure to solve it correctly in 5 minutes is an automatic no-hire. The interviewer is grading three things: (1) is the divisibility-by-15-first order correct, (2) does the output type match (strings, not mixed types), (3) is the code idiomatic in the language. Don't overthink — write the cascade version cleanly and move on.
Common mistakes
- Checking 3 first, then 5, and never reaching the FizzBuzz branch.
- Pushing the integer for the default case instead of String(i) — the output array must be all strings.
- Starting at 0 instead of 1 — the problem says 1-indexed and 0 is divisible by everything.
Follow-up questions
An interviewer at Goldman Sachs may pivot to one of these next:
- Generalize to N rules: 'Fizz on 3, Buzz on 5, Bang on 7' — design a clean API that lets the caller add new (divisor, label) pairs.
- What if you couldn't use modulo? (Maintain three running counters that reset.)
- Print Fizz Buzz from 1 to 10^9 — would the string concat version still fit in memory? (No; streaming-print needed.)
Solve it now
Free. No sign-up. Python and JavaScript run instantly in your browser.
FAQ
Why does Goldman ask Fizz Buzz?
Because some non-trivial fraction of CS graduates can't write it correctly in 5 minutes under interview pressure. The question is a coarse filter — passing it doesn't get you the offer, but failing it ends the interview.
Is the string-concat version actually preferred over the cascade?
Both are accepted, but the concat version generalizes better. If the interviewer follows up with 'now add Bang on 7', the concat version takes 2 lines while the cascade explodes combinatorially. State both and let them pick.
Free learning resources
Curated free links for this problem.
Practice these live with InterviewChamp.AI
Drill Fizz Buzz and other Goldman Sachs interview questions under real-loop conditions with instant feedback on your reasoning, complexity claims, and code.
Practice these live with InterviewChamp.AI →