← BACK TO VIDEOS

Finding a pair in an array

PLANNED RECORDING

Walkthrough outline

Compare a nested loop with a one-pass hash map.

EasyArraysInterview walkthrough

Approach

Track previously seen values in a map. For each value, check whether its complement has already appeared. Expected time: O(n); extra space: O(n).

Video and solution links will be added after recording.