File tree Expand file tree Collapse file tree 1 file changed +12
-12
lines changed Expand file tree Collapse file tree 1 file changed +12
-12
lines changed Original file line number Diff line number Diff line change @@ -5,20 +5,20 @@ class TwoSum {
5
5
public:
6
6
7
7
// Add the number to an internal data structure.
8
- void add (int number) {
9
- ++lookup_[number];
10
- }
8
+ void add (int number) {
9
+ ++lookup_[number];
10
+ }
11
11
12
12
// Find if there exists any pair of numbers which sum is equal to the value.
13
- bool find (int value) {
14
- for (const auto & kvp : lookup_) {
15
- const auto num = value - kvp.first ;
16
- if (lookup_.count (num) && (num != kvp.first || kvp.second > 1 )) {
17
- return true ;
18
- }
19
- }
20
- return false ;
21
- }
13
+ bool find (int value) {
14
+ for (const auto & kvp : lookup_) {
15
+ const auto num = value - kvp.first ;
16
+ if (lookup_.count (num) && (num != kvp.first || kvp.second > 1 )) {
17
+ return true ;
18
+ }
19
+ }
20
+ return false ;
21
+ }
22
22
23
23
private:
24
24
unordered_map<int , int > lookup_;
You can’t perform that action at this time.
0 commit comments