mirror of
https://github.com/krahets/hello-algo.git
synced 2026-08-16 21:50:59 +00:00
fix: Several code bug fixes (#973)
* Update counting_sort.c and quick_sort.c * Code bug fixes.
This commit is contained in:
@@ -51,7 +51,7 @@ func (m *hashMapOpenAddressing) get(key int) string {
|
||||
// 线性探测,从 index 开始向后遍历
|
||||
for i := 0; i < m.capacity; i++ {
|
||||
// 计算桶索引,越过尾部返回头部
|
||||
j := (idx + 1) % m.capacity
|
||||
j := (idx + i) % m.capacity
|
||||
// 若遇到空桶,说明无此 key ,则返回 null
|
||||
if m.buckets[j] == (pair{}) {
|
||||
return ""
|
||||
@@ -99,7 +99,7 @@ func (m *hashMapOpenAddressing) remove(key int) {
|
||||
// 线性探测,从 index 开始向后遍历
|
||||
for i := 0; i < m.capacity; i++ {
|
||||
// 计算桶索引,越过尾部返回头部
|
||||
j := (idx + 1) % m.capacity
|
||||
j := (idx + i) % m.capacity
|
||||
// 若遇到空桶,说明无此 key ,则直接返回
|
||||
if m.buckets[j] == (pair{}) {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user