天天看点

170 Two Sum III - Data structure design

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

<code>add</code> - Add the number to an internal data structure.

<code>find</code> - Find if there exists any pair of numbers which sum is equal to the value.

Example 1:

Example 2:

继续阅读