mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-09 03:34:02 +08:00
添加 0454.四数相加II go版本
This commit is contained in:
@ -154,6 +154,23 @@ class Solution(object):
|
|||||||
|
|
||||||
|
|
||||||
Go:
|
Go:
|
||||||
|
```go
|
||||||
|
func fourSumCount(nums1 []int, nums2 []int, nums3 []int, nums4 []int) int {
|
||||||
|
m := make(map[int]int)
|
||||||
|
count := 0
|
||||||
|
for _, v1 := range nums1 {
|
||||||
|
for _, v2 := range nums2 {
|
||||||
|
m[v1+v2]++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, v3 := range nums3 {
|
||||||
|
for _, v4 := range nums4 {
|
||||||
|
count += m[-v3-v4]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
javaScript:
|
javaScript:
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user