From d6e680498b4375a06bff36a37ed274ecd5cf3373 Mon Sep 17 00:00:00 2001 From: zen <43899716+zenwangzy@users.noreply.github.com> Date: Wed, 5 Mar 2025 00:00:17 +0800 Subject: [PATCH] =?UTF-8?q?Update=200454.=E5=9B=9B=E6=95=B0=E7=9B=B8?= =?UTF-8?q?=E5=8A=A0II.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 0454-四数相加,力扣函数参数更新,故更新对应题解代码 --- ...5\233\233\346\225\260\347\233\270\345\212\240II.md" | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git "a/problems/0454.\345\233\233\346\225\260\347\233\270\345\212\240II.md" "b/problems/0454.\345\233\233\346\225\260\347\233\270\345\212\240II.md" index af19f5f7d8..2138590c31 100644 --- "a/problems/0454.\345\233\233\346\225\260\347\233\270\345\212\240II.md" +++ "b/problems/0454.\345\233\233\346\225\260\347\233\270\345\212\240II.md" @@ -62,18 +62,18 @@ C++代码: ```CPP class Solution { public: - int fourSumCount(vector& A, vector& B, vector& C, vector& D) { + int fourSumCount(vector& nums1, vector& nums2, vector& nums3, vector& nums4) { unordered_map umap; //key:a+b的数值,value:a+b数值出现的次数 // 遍历大A和大B数组,统计两个数组元素之和,和出现的次数,放到map中 - for (int a : A) { - for (int b : B) { + for (int a : nums1) { + for (int b : nums2) { umap[a + b]++; } } int count = 0; // 统计a+b+c+d = 0 出现的次数 // 再遍历大C和大D数组,找到如果 0-(c+d) 在map中出现过的话,就把map中key对应的value也就是出现次数统计出来。 - for (int c : C) { - for (int d : D) { + for (int c : nums3) { + for (int d : nums4) { if (umap.find(0 - (c + d)) != umap.end()) { count += umap[0 - (c + d)]; }