2dbi
Home/Dropbox/Two Sum / Hashmap Medium
DDropbox·DSASDE-2Technical Phone Screen

Two Sum / Hashmap Medium

Problem

Return indices of two numbers summing to a target.

Example

[2,7,11,15], 9 -> [0,1]

Constraints

  • 2 ≤ n ≤ 10^4

Approach

Hash map, O(n). Dropbox OA (CodeSignal) is timed and can be brutal — speed + correctness.

added 6 days ago
LeadersAccount