代码拉取完成,页面将自动刷新
package main
type TwoSum struct {
book map[int]int
}
/** Initialize your data structure here. */
func Constructor() TwoSum {
return TwoSum{
make(map[int]int),
}
}
/** Add the number to an internal data structure.. */
func (this *TwoSum) Add(number int) {
this.book[number]++
}
/** Find if there exists any pair of numbers which sum is equal to the value. */
func (this *TwoSum) Find(value int) bool {
for key := range this.book {
if times, ok := this.book[value-key]; ok {
if value-key == key && times >= 2 {
return true
} else if value-key != key {
return true
}
}
}
return false
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。