mirror of
https://github.com/halfrost/LeetCode-Go.git
synced 2025-07-05 00:25:22 +08:00
Merge pull request #226 from kinsolee/master
fix 706: bug with edge case
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
package leetcode
|
||||
|
||||
const Len int = 100000
|
||||
const Len int = 10000
|
||||
|
||||
type MyHashMap struct {
|
||||
content [Len]*HashNode
|
||||
@ -41,9 +41,9 @@ func (N *HashNode) Remove(key int) *HashNode {
|
||||
return p
|
||||
}
|
||||
if N.next != nil {
|
||||
return N.next.Remove(key)
|
||||
N.next = N.next.Remove(key)
|
||||
}
|
||||
return nil
|
||||
return N
|
||||
}
|
||||
|
||||
/** Initialize your data structure here. */
|
||||
|
@ -13,6 +13,9 @@ func Test_Problem706(t *testing.T) {
|
||||
fmt.Printf("Contains 7 = %v\n", obj.Get(7))
|
||||
param1 := obj.Get(100)
|
||||
fmt.Printf("param1 = %v\n", param1)
|
||||
obj.Remove(100007)
|
||||
param1 = obj.Get(7)
|
||||
fmt.Printf("param1 = %v\n", param1)
|
||||
obj.Remove(7)
|
||||
param1 = obj.Get(7)
|
||||
fmt.Printf("param1 = %v\n", param1)
|
||||
|
@ -98,9 +98,9 @@ func (N *HashNode) Remove(key int) *HashNode {
|
||||
return p
|
||||
}
|
||||
if N.next != nil {
|
||||
return N.next.Remove(key)
|
||||
N.next = N.next.Remove(key)
|
||||
}
|
||||
return nil
|
||||
return N
|
||||
}
|
||||
|
||||
/** Initialize your data structure here. */
|
||||
|
Reference in New Issue
Block a user