题解 | 整数对查找
整数对查找
https://www.nowcoder.com/practice/87d5a092a1d647479103e519a6c0a205
#include <algorithm>
#include <unordered_map>
class FindPair {
public:
int countPairs(vector<int> A, int n, int sum) {
// write code here
unordered_map<int, int> left_map;
int count =0;
for(auto a:A){
count+= left_map[sum-a];
left_map[a]++;
}
return count;
}
};

vivo公司福利 365人发布