当前位置:网站首页>Leetcode -- addition of four numbers II
Leetcode -- addition of four numbers II
2022-07-25 13:44:00 【Peihj2021】
Add four numbers II
Topic link : Add four numbers 2
Title Description

Topic analysis
Video analysis address :B standing
Code
class Solution {
public int fourSumCount(int[] nums1, int[] nums2, int[] nums3, int[] nums4) {
HashMap<Integer,Integer> hashMap = new HashMap<>();
int res = 0;
for (int i : nums1) {
for (int i1 : nums2) {
int sum1 = i + i1;
if (hashMap.containsKey(sum1)){
hashMap.put(sum1,hashMap.get(sum1)+1);
}else {
hashMap.put(sum1,1);
}
}
}
for (int j : nums3) {
for (int j1 : nums4) {
int target = 0 - (j + j1);
if (hashMap.containsKey(target)){
res += hashMap.get(target);
}
}
}
return res;
}
}

Reference resources
https://programmercarl.com/0454.%E5%9B%9B%E6%95%B0%E7%9B%B8%E5%8A%A0II.html#%E5%85%B6%E4%BB%96%E8%AF%AD%E8%A8%80%E7%89%88%E6%9C%AC
边栏推荐
- 并发编程之AQS
- 手写jdbc的使用步骤?
- Peripheral system calls SAP's webapi interface
- 0715RHCSA
- Applet sharing function
- 嵌入式代码如何进行重构?
- leetcode1 --两数之和
- How to solve the problem of taking up too much space when recording and editing videos?
- Applet enterprise red envelope function
- What is your revenue rank among global developers in 2022?
猜你喜欢

QGIS loading online map: Gaode, Tiandi map, etc

What is your revenue rank among global developers in 2022?

嵌入式代码如何进行重构?

Concurrent programming - memory model JMM

leetcode202---快乐数

G027-op-ins-rhel-04 RedHat openstack creates a customized qcow2 format image
![[configure hifive1 revb] the device manager does not recognize the port, and can not connect to j-link via USB](/img/55/a8acdd63a17bf9e3072c9a04babe79.png)
[configure hifive1 revb] the device manager does not recognize the port, and can not connect to j-link via USB

DNS resolution error during windows unbutu20 lts apt, WGet installation

Friends let me see this code

刷题-洛谷-P1035 级数求和
随机推荐
Int array get duplicate data
刷题-洛谷-P1085 不高兴的津津
Friends let me see this code
互斥锁、自旋锁、读写锁……理清它们的区别和应用
命名空间与库
Basic knowledge of binary tree
飞盘局有多快乐?2022年轻人新潮运动报告
How can information security engineers prepare for the soft exam in the second half of 2022?
职场「数字人」不吃不睡007工作制,你「卷」得过它们吗?
In order to improve efficiency, there are various problems when using parallelstream
Uniapp handles background transfer pictures
int数组获取重复数据
Prepare for 2022 csp-j1 2022 csp-s1 preliminaries video set
C # basic learning (XXIII)_ Forms and events
0720RHCSA
Leetcode 113. 路径总和 II
pytest.mark.parametrize及mock使用
leetcode202---快乐数
Hcip day 9 notes
刷题-洛谷-P1075 质因数分解