Skip to content

Commit

Permalink
fix Two Sum bug
Browse files Browse the repository at this point in the history
  • Loading branch information
gaodayue committed Jan 12, 2014
1 parent c7111b2 commit 6cd8bab
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion C++/chapLinearList.tex
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ \subsubsection{代码}
}
for (int i = 0; i < num.size(); i++) {
const int gap = target - num[i];
if (mapping.find(gap) != mapping.end()) {
if (mapping.find(gap) != mapping.end() && mapping[gap] > i) {
result.push_back(i + 1);
result.push_back(mapping[gap] + 1);
break;
Expand Down

0 comments on commit 6cd8bab

Please sign in to comment.