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