1. Two Sum
easyAsked at FigmaGiven an array of integers and a target, return the indices of the two numbers that add up to the target. Figma uses this as the warm-up where they watch how cleanly you translate 'looking up the complement' into a hash-map insight, a habit that recurs constantly in their scene-graph node lookups.
By Alex Chen, Founder, InterviewChamp.AI · Last verified
Source citations
Public interview reports confirming this problem appears in Figma loops.
- Glassdoor (2026-Q1)— Figma phone-screen warm-up, IC3/IC4 level.
- Blind (2025-09)— Reported as the first 5-minute question in Figma OAs.
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]Approaches
1. Brute-force double loop
Try every pair (i, j) with i < j.
- Time
- O(n^2)
- Space
- O(1)
function twoSum(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];
}
}
}Tradeoff: Quadratic. Misses the obvious 'have I seen target - x before?' insight.
2. One-pass hash map
Walk once, store value -> index. At each x check if target - x is already stored.
- 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: Single pass; the order 'check then insert' matters — inserting first would let an element pair with itself.
Figma-specific tips
Figma uses Two Sum as a low-cost litmus test for whether you reach for hash maps before you reach for nested loops, since their scene-graph code constantly maps node IDs to nodes during multiplayer broadcast. Articulate the 'have I seen the complement?' framing aloud — that one sentence usually decides whether the interviewer marks the warm-up as 'strong' or 'fine.'
Common mistakes
- Inserting nums[i] into the map BEFORE checking — accidentally lets nums[i] pair with itself when target is 2*nums[i].
- Returning the values instead of the indices.
- Using a Set instead of a Map — you lose the index needed for the return value.
Follow-up questions
An interviewer at Figma may pivot to one of these next:
- Two Sum II — input is sorted (use two pointers, O(1) space).
- 3Sum — extend to triples (LC 15).
- Two Sum with multiple valid pairs — return all unique pairs.
Solve it now
Free. No sign-up. Python and JavaScript run instantly in your browser.
FAQ
Why one pass and not two?
Two passes work but require thinking through 'what if the same index?' edge case. One pass naturally avoids it because the complement is only looked up against entries inserted earlier.
Can I sort first and use two pointers?
You'd lose the original indices unless you sort (value, index) pairs. That's O(n log n) vs hash map's O(n), so it's strictly worse here.
Practice these live with InterviewChamp.AI
Drill Two Sum and other Figma interview questions under real-loop conditions with instant feedback on your reasoning, complexity claims, and code.
Practice these live with InterviewChamp.AI →