1. Two Sum
easyAsked at BloombergTwo Sum is the canonical Bloomberg warm-up: return the indices of two numbers in an array that add to a given target. Bloomberg uses it on phone screens to gauge whether you can narrate the space-for-time tradeoff before reaching for the optimal one-pass hash map.
By Alex Chen, Founder, InterviewChamp.AI · Last verified
Source citations
Public interview reports confirming this problem appears in Bloomberg loops.
- Glassdoor (2026-Q1)— Recurring in Bloomberg SWE phone-screen reports as a 10-minute warm-up before the harder follow-up.
- Blind (2025-12)— Bloomberg new-grad SWE candidates report Two Sum as the opener in the technical round.
Problem
Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order.
Constraints
2 <= nums.length <= 10^4-10^9 <= nums[i] <= 10^9-10^9 <= target <= 10^9Only one valid answer exists.
Examples
Example 1
nums = [2,7,11,15], target = 9[0,1]Explanation: nums[0] + nums[1] == 9.
Example 2
nums = [3,2,4], target = 6[1,2]Example 3
nums = [3,3], target = 6[0,1]Approaches
1. Brute-force nested loops
Try every (i, j) pair with i < j and return when nums[i] + nums[j] == target.
- Time
- O(n^2)
- Space
- O(1)
function twoSumBrute(nums, target) {
for (let i = 0; i < nums.length; i++) {
for (let j = i + 1; j < nums.length; j++) {
if (nums[i] + nums[j] === target) return [i, j];
}
}
return [];
}Tradeoff: Simplest to reason about and zero extra space. Mention out loud, then move on — at Bloomberg, jumping straight to the optimal without naming the brute force is a flag.
2. Hash map one-pass (optimal)
Scan once; for each num, check if target - num is already in the map. Else store num -> index.
- Time
- O(n)
- Space
- O(n)
function twoSum(nums, target) {
const seen = new Map();
for (let i = 0; i < nums.length; i++) {
const need = target - nums[i];
if (seen.has(need)) return [seen.get(need), i];
seen.set(nums[i], i);
}
return [];
}Tradeoff: Trade O(n) space for O(n) time. One pass works because by the time you'd want to pair X with Y, you've already inserted whichever appeared first.
Bloomberg-specific tips
Bloomberg interviewers grade on the BRUTE-FORCE NARRATION as much as the final code. State the O(n^2) cost in plain language, then say 'I can trade space for time with a hash map' and write the one-pass solution. Bloomberg's rubric explicitly tests whether you can reason about tradeoffs — not just produce a working answer.
Common mistakes
- Returning the values instead of the indices.
- Using a hash map but writing it as two passes (build then lookup) when a one-pass is cleaner.
- Forgetting that duplicates can appear (nums = [3,3] with target 6 returns [0,1]).
Follow-up questions
An interviewer at Bloomberg may pivot to one of these next:
- Two Sum II - Input Array Is Sorted (LC 167) — two-pointer in O(1) extra space.
- 3Sum (LC 15) — sort + fix one + two-pointer the rest.
- What if we wanted all pairs that sum to target? (Frequency map + duplicate handling.)
Solve it now
Free. No sign-up. Python and JavaScript run instantly in your browser.
FAQ
Does Bloomberg still ask Two Sum in 2026?
Yes — most commonly as a 10-minute warm-up on the phone screen before the harder follow-up. Expect a pivot to a sorted-array or 3Sum variant within the same hour.
Is the one-pass hash map actually expected, or is two-pass acceptable?
Both pass on correctness, but one-pass is the canonical answer at Bloomberg because it demonstrates you understand the invariant — when you arrive at index i, the map already contains every prior index, so any pair whose later half is i has its earlier half stored.
Free learning resources
Curated free links for this problem.
Practice these live with InterviewChamp.AI
Drill Two Sum and other Bloomberg interview questions under real-loop conditions with instant feedback on your reasoning, complexity claims, and code.
Practice these live with InterviewChamp.AI →