乔拓云建站有免费的吗,哪个网站有做彩平的材质贴图,做网站的首页下拉列表,网站举报查询进度四数相加 leetcode454 
本题如果直接进行四次for循环#xff0c;则时间复杂度为O(N^4),超出运行时间限制。 因此我们这里使用两个分别的for循环进行遍历#xff0c;则时间复杂度为O(N2N2). 
/ 使用两遍for循环
func fourSumCount(nums1 []int, nums2 []int, nums3 []int, num…四数相加 leetcode454 
本题如果直接进行四次for循环则时间复杂度为O(N^4),超出运行时间限制。 因此我们这里使用两个分别的for循环进行遍历则时间复杂度为O(N2N2). 
/ 使用两遍for循环
func fourSumCount(nums1 []int, nums2 []int, nums3 []int, nums4 []int) int {index : 0record : map[int]int{}//首先对num3、nums4进行遍历记录数据	考虑到可能每组有重复数字每遍历到一次就1for _, i1 : range nums3 {for _, i2 : range nums4 {record[i1i2]}}//然后再进行nums1、nums2的遍历for _, i1 : range nums1 {for _, i2 : range nums2 {//record对应数字是几证明能得到这个数字的组合有几个这里就加上对应的组合数if v, ok : record[-i1-i2]; ok {index  index  v}}}return index
}