代码拉取完成,页面将自动刷新
package two_point
import C "gitee.com/ljfirst/algo-go-sdk/common/constant"
/**
* @author ljfirst
* @version V1.0
* @date 2023/7/27 15:49
* @author-Email ljfirst@mail.ustc.edu.cn
* @blogURL https://blog.csdn.net/ljfirst
* @description
**/
type TwoSumByMap struct {
}
func (m *TwoSumByMap) Method(array []int, target int) []int {
if len(array) == 0 {
return nil
}
sumMap := make(map[int]bool, 0)
for _, v := range array {
_, exist := sumMap[target-v]
if exist {
return []int{target - v, v}
} else {
sumMap[v] = true
}
}
return nil
}
func (m *TwoSumByMap) GetAttribute() *C.Attribute {
return &C.Attribute{
Tags: []string{},
Desc: &C.Desc{
Name: "TwoSumByMap",
NameCn: "两数之和",
Description: "",
ParamsDesc: map[string]string{
},
Example: map[int]string{
},
},
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。