pull/858/head
krahets 1 year ago
parent 227bd66223
commit da5ef293d9

@ -1,5 +1,5 @@
If this PR is related to coding or code translation, please fill out the checklist and paste the console outputs to the PR. If this PR is related to coding or code translation, please fill out the checklist and paste the console outputs to the PR.
- [ ] I've tested the code and ensured the outputs are the same as the outputs of reference codes. - [ ] I've tested the code and ensured the outputs are the same as the outputs of reference code.
- [ ] I've checked the codes (formatting, comments, indentation, file header, etc) carefully. - [ ] I've checked the code (formatting, comments, indentation, file header, etc) carefully.
- [ ] The code does not rely on a particular environment or IDE and can be executed on a standard system (Win, macOS, Ubuntu). - [ ] The code does not rely on a particular environment or IDE and can be executed on a standard system (Win, macOS, Ubuntu).

@ -66,7 +66,7 @@ function find(nums, target) {
return -1; return -1;
} }
/* Driver Codes*/ /* Driver Code */
/* 初始化数组 */ /* 初始化数组 */
const arr = new Array(5).fill(0); const arr = new Array(5).fill(0);
console.log('数组 arr =', arr); console.log('数组 arr =', arr);

@ -53,7 +53,7 @@ class HashMapOpenAddressing {
// 若遇到指定 key ,则返回对应 val // 若遇到指定 key ,则返回对应 val
if ( if (
this.#buckets[j].key === key && this.#buckets[j].key === key &&
this.#buckets[j][key] !== this.#removed.key this.#buckets[j].key !== this.#removed.key
) )
return this.#buckets[j].val; return this.#buckets[j].val;
} }
@ -74,7 +74,7 @@ class HashMapOpenAddressing {
// 若遇到空桶、或带有删除标记的桶,则将键值对放入该桶 // 若遇到空桶、或带有删除标记的桶,则将键值对放入该桶
if ( if (
this.#buckets[j] === null || this.#buckets[j] === null ||
this.#buckets[j][key] === this.#removed.key this.#buckets[j].key === this.#removed.key
) { ) {
this.#buckets[j] = new Pair(key, val); this.#buckets[j] = new Pair(key, val);
this.#size += 1; this.#size += 1;

@ -2,7 +2,7 @@
# https://peps.python.org/pep-0585/ # https://peps.python.org/pep-0585/
from __future__ import annotations from __future__ import annotations
# Import common libs here to simplify the codes by `from module import *` # Import common libs here to simplify the code by `from module import *`
from .list_node import ( from .list_node import (
ListNode, ListNode,
list_to_linked_list, list_to_linked_list,

@ -55,7 +55,7 @@ class HashMapOpenAddressing {
// 若遇到指定 key ,则返回对应 val // 若遇到指定 key ,则返回对应 val
if ( if (
this.#buckets[j].key === key && this.#buckets[j].key === key &&
this.#buckets[j][key] !== this.#removed.key this.#buckets[j].key !== this.#removed.key
) )
return this.#buckets[j].val; return this.#buckets[j].val;
} }
@ -76,7 +76,7 @@ class HashMapOpenAddressing {
// 若遇到空桶、或带有删除标记的桶,则将键值对放入该桶 // 若遇到空桶、或带有删除标记的桶,则将键值对放入该桶
if ( if (
this.#buckets[j] === null || this.#buckets[j] === null ||
this.#buckets[j][key] === this.#removed.key this.#buckets[j].key === this.#removed.key
) { ) {
this.#buckets[j] = new Pair(key, val); this.#buckets[j] = new Pair(key, val);
this.#size += 1; this.#size += 1;

@ -22,7 +22,7 @@ hide:
</a> </a>
&nbsp; &nbsp;
<a href="https://github.com/krahets/hello-algo"> <a href="https://github.com/krahets/hello-algo">
<img alt="GitHub contributors" src="https://img.shields.io/github/contributors-anon/krahets/hello-algo?style=social&logo=handshake&logoColor=%23101010"> <img alt="GitHub contributors" src="https://img.shields.io/github/contributors-anon/krahets/hello-algo?style=social&logo=git&logoColor=%23101010">
</a> </a>
</p> </p>

Loading…
Cancel
Save