Skip to content

Commit b0e7057

Browse files
authored
Update find-k-pairs-with-smallest-sums.cpp
1 parent d482676 commit b0e7057

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

C++/find-k-pairs-with-smallest-sums.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Solution {
2222
};
2323

2424
push(0, 0);
25-
while (k-- && !q.empty()) {
25+
while (!q.empty() && pairs.size() < k) {
2626
auto tmp = q.top(); q.pop();
2727
int i, j;
2828
tie(i, j) = tmp.second;

0 commit comments

Comments
 (0)