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.
1 parent 5bd753f commit d6e6804Copy full SHA for d6e6804
problems/0454.四数相加II.md
@@ -62,18 +62,18 @@ C++代码:
62
```CPP
63
class Solution {
64
public:
65
- 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) {
66
unordered_map<int, int> umap; //key:a+b的数值,value:a+b数值出现的次数
67
// 遍历大A和大B数组,统计两个数组元素之和,和出现的次数,放到map中
68
- for (int a : A) {
69
- for (int b : B) {
+ for (int a : nums1) {
+ for (int b : nums2) {
70
umap[a + b]++;
71
}
72
73
int count = 0; // 统计a+b+c+d = 0 出现的次数
74
// 再遍历大C和大D数组,找到如果 0-(c+d) 在map中出现过的话,就把map中key对应的value也就是出现次数统计出来。
75
- for (int c : C) {
76
- for (int d : D) {
+ for (int c : nums3) {
+ for (int d : nums4) {
77
if (umap.find(0 - (c + d)) != umap.end()) {
78
count += umap[0 - (c + d)];
79
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
0 commit comments