Skip to content

Commit

Permalink
Merge pull request soulmachine#13 from gaodayue/master
Browse files Browse the repository at this point in the history
fix Two Sum bug
  • Loading branch information
soulmachine committed Jan 16, 2014
2 parents c7111b2 + 6cd8bab commit 1257dda
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 1257dda

Please sign in to comment.