mirror of
https://github.com/krahets/hello-algo.git
synced 2025-07-07 23:04:55 +08:00
Simplify the declarations of the Python code.
This commit is contained in:
@ -23,7 +23,7 @@ class ArrayHashMap:
|
||||
|
||||
def hash_func(self, key: int) -> int:
|
||||
"""哈希函数"""
|
||||
index: int = key % 100
|
||||
index = key % 100
|
||||
return index
|
||||
|
||||
def get(self, key: int) -> str:
|
||||
@ -56,7 +56,7 @@ class ArrayHashMap:
|
||||
|
||||
def key_set(self) -> list[int]:
|
||||
"""获取所有键"""
|
||||
result: list[int] = []
|
||||
result = []
|
||||
for pair in self.buckets:
|
||||
if pair is not None:
|
||||
result.append(pair.key)
|
||||
@ -64,7 +64,7 @@ class ArrayHashMap:
|
||||
|
||||
def value_set(self) -> list[str]:
|
||||
"""获取所有值"""
|
||||
result: list[str] = []
|
||||
result = []
|
||||
for pair in self.buckets:
|
||||
if pair is not None:
|
||||
result.append(pair.val)
|
||||
|
Reference in New Issue
Block a user