We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents a6caded + d6e6804 commit 784437bCopy full SHA for 784437b
problems/0454.四数相加II.md
@@ -60,18 +60,18 @@ C++代码:
60
```CPP
61
class Solution {
62
public:
63
- int fourSumCount(vector<int>& A, vector<int>& B, vector<int>& C, vector<int>& D) {
+ int fourSumCount(vector<int>& nums1, vector<int>& nums2, vector<int>& nums3, vector<int>& nums4) {
64
unordered_map<int, int> umap; //key:a+b的数值,value:a+b数值出现的次数
65
// 遍历大A和大B数组,统计两个数组元素之和,和出现的次数,放到map中
66
- for (int a : A) {
67
- for (int b : B) {
+ for (int a : nums1) {
+ for (int b : nums2) {
68
umap[a + b]++;
69
}
70
71
int count = 0; // 统计a+b+c+d = 0 出现的次数
72
// 再遍历大C和大D数组,找到如果 0-(c+d) 在map中出现过的话,就把map中key对应的value也就是出现次数统计出来。
73
- for (int c : C) {
74
- for (int d : D) {
+ for (int c : nums3) {
+ for (int d : nums4) {
75
if (umap.find(0 - (c + d)) != umap.end()) {
76
count += umap[0 - (c + d)];
77
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
0 commit comments