Skip to content

Commit 7d3641c

Browse files
committed
Create README - LeetHub
1 parent a83a8ae commit 7d3641c

File tree

1 file changed

+37
-0
lines changed
  • 0170-two-sum-iii-data-structure-design

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<h2><a href="https://leetcode.com/problems/two-sum-iii-data-structure-design">170. Two Sum III - Data structure design</a></h2><h3>Easy</h3><hr><p>Design a data structure that accepts a stream of integers and checks if it has a pair of integers that sum up to a particular value.</p>
2+
3+
<p>Implement the <code>TwoSum</code> class:</p>
4+
5+
<ul>
6+
<li><code>TwoSum()</code> Initializes the <code>TwoSum</code> object, with an empty array initially.</li>
7+
<li><code>void add(int number)</code> Adds <code>number</code> to the data structure.</li>
8+
<li><code>boolean find(int value)</code> Returns <code>true</code> if there exists any pair of numbers whose sum is equal to <code>value</code>, otherwise, it returns <code>false</code>.</li>
9+
</ul>
10+
11+
<p>&nbsp;</p>
12+
<p><strong class="example">Example 1:</strong></p>
13+
14+
<pre>
15+
<strong>Input</strong>
16+
[&quot;TwoSum&quot;, &quot;add&quot;, &quot;add&quot;, &quot;add&quot;, &quot;find&quot;, &quot;find&quot;]
17+
[[], [1], [3], [5], [4], [7]]
18+
<strong>Output</strong>
19+
[null, null, null, null, true, false]
20+
21+
<strong>Explanation</strong>
22+
TwoSum twoSum = new TwoSum();
23+
twoSum.add(1); // [] --&gt; [1]
24+
twoSum.add(3); // [1] --&gt; [1,3]
25+
twoSum.add(5); // [1,3] --&gt; [1,3,5]
26+
twoSum.find(4); // 1 + 3 = 4, return true
27+
twoSum.find(7); // No two integers sum up to 7, return false
28+
</pre>
29+
30+
<p>&nbsp;</p>
31+
<p><strong>Constraints:</strong></p>
32+
33+
<ul>
34+
<li><code>-10<sup>5</sup> &lt;= number &lt;= 10<sup>5</sup></code></li>
35+
<li><code>-2<sup>31</sup> &lt;= value &lt;= 2<sup>31</sup> - 1</code></li>
36+
<li>At most <code>10<sup>4</sup></code> calls will be made to <code>add</code> and <code>find</code>.</li>
37+
</ul>

0 commit comments

Comments
 (0)