当前位置:网站首页>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
边栏推荐
- stable_ Baselines quick start
- What is your revenue rank among global developers in 2022?
- Excel record macro
- The migration of arm architecture to alsa lib and alsa utils is smooth
- 0715RHCSA
- 2022年下半年软考信息安全工程师如何备考?
- DNS resolution error during windows unbutu20 lts apt, WGet installation
- window unbutu20 LTS apt,wget 安装时 DNS 解析错误
- 刷题-洛谷-P1059 明明的随机数
- mujoco_py中文文档
猜你喜欢

Excel add key run macro

0710RHCSA

uniapp处理后台传输图片

刷题-洛谷-P1059 明明的随机数

Install mujoco and report an error: distutils.errors DistutilsExecError: command ‘gcc‘ failed with exit status 1

LabVIEW的内部错误
![[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

0715RHCSA

刷题-洛谷-P1152 欢乐的跳

window unbutu20 LTS apt,wget 安装时 DNS 解析错误
随机推荐
领域驱动模型设计与微服务架构落地-模型设计
电脑里一辈子都不想删的神仙软件
Azure Devops (XIV) use azure's private nuget warehouse
刷题-洛谷-P1085 不高兴的津津
刷题-洛谷-P1152 欢乐的跳
@classmethod 装饰器
ES6 array de duplication new set()
IM system - some common problems of message streaming
HTTP cache tongtianpian, there may be something you want
0720RHCSA
Canvas judgment content is empty
In order to improve efficiency, there are various problems when using parallelstream
Online Learning and Pricing with Reusable Resources: Linear Bandits with Sub-Exponential Rewards: Li
adb通过Wi-Fi连接小米手机
Mujoco+spinningup for intensive learning training quick start
hcip第八天实验
Mxnet implementation of densenet (dense connection network)
@Classmethod decorator
@Wrap decorator
AQS of concurrent programming