Reference: LeetCode
Difficulty: Easy

## Problem

Design and implement a TwoSum class. It should support the following operations: add and find.

• add - Add the number to an internal data structure.
• find - Find if there exists any pair of numbers which sum is equal to the value.

Example:

## Analysis

### Two Sets

Time: add would take $O(N)$ time each time.
Space: Since we have sums set, it takes $O(N^2)$ space.

### Count Map

Time: find takes $O(N)$.
Space: $O(N)$

Comment
Junhao Wang
Hi, I was a master student at USC studying Computer Science.