当前位置:网站首页>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
边栏推荐
- MySQL 01: Source command
- hcip第九天笔记
- Prepare for 2022 csp-j1 2022 csp-s1 preliminaries video set
- Applet H5 get mobile number scheme
- 领域驱动模型设计与微服务架构落地-模型设计
- Okaleido launched the fusion mining mode, which is the only way for Oka to verify the current output
- pytest.mark.parametrize及mock使用
- Vscode plug-in development
- Online Learning and Pricing with Reusable Resources: Linear Bandits with Sub-Exponential Rewards: Li
- 并发编程之阻塞队列
猜你喜欢
![[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

JS array indexof includes sort() colon sort quick sort de duplication and random sample random

Error: cannot find or load main class XXXX

Basic knowledge of binary tree

刷题-洛谷-P1047 校门外的树

Discussion on principle and application technology of MLIR

ES6 array de duplication new set()

Redis visualizer RDM installation package sharing

GCD details

ES6数组去重 new Set()
随机推荐
Sword finger offer special assault edition day 10
Hcip day 9 notes
刷题-洛谷-P1152 欢乐的跳
hcip第十天笔记
Nodejs link MySQL error: Er_ NOT_ SUPPORTED_ AUTH_ MODEError: ER_ NOT_ SUPPORTED_ AUTH_ MODE
嵌入式代码如何进行重构?
ADB connects to Xiaomi mobile phone via Wi Fi
Sports luxury or safety luxury? Which type of Asian Dragon and Volvo S60 should we start with?
pycharm不能输入中文解决方法
Online Learning and Pricing with Reusable Resources: Linear Bandits with Sub-Exponential Rewards: Li
Preparing for the soft test for junior programmers in the second half of 2022
Okaleido上线聚变Mining模式,OKA通证当下产出的唯一方式
ES6 array de duplication new set()
Immortal software in the computer that I don't want to delete all my life
移动端网站,独立APP,网站排名策略有哪些?
音视频技术开发周刊 | 255
How to realize the configuration method of user password free login?
@wrap 装饰器
Leetcode 113. 路径总和 II
What is your revenue rank among global developers in 2022?