mirror of
https://github.com/TheAlgorithms/Python.git
synced 2026-03-13 09:50:19 +08:00
refactor: Replace list() and dict() calls with literals (#7198)
This commit is contained in:
@@ -160,7 +160,7 @@ def postorder(curr_node):
|
||||
"""
|
||||
postOrder (left, right, self)
|
||||
"""
|
||||
node_list = list()
|
||||
node_list = []
|
||||
if curr_node is not None:
|
||||
node_list = postorder(curr_node.left) + postorder(curr_node.right) + [curr_node]
|
||||
return node_list
|
||||
|
||||
@@ -9,7 +9,7 @@ class Heap:
|
||||
|
||||
def __init__(self, key: Callable | None = None) -> None:
|
||||
# Stores actual heap items.
|
||||
self.arr: list = list()
|
||||
self.arr: list = []
|
||||
# Stores indexes of each item for supporting updates and deletion.
|
||||
self.pos_map: dict = {}
|
||||
# Stores current size of heap.
|
||||
|
||||
@@ -8,7 +8,7 @@ longest word)) lookup time making it an optimal approach when space is not an is
|
||||
|
||||
class TrieNode:
|
||||
def __init__(self) -> None:
|
||||
self.nodes: dict[str, TrieNode] = dict() # Mapping from char to TrieNode
|
||||
self.nodes: dict[str, TrieNode] = {} # Mapping from char to TrieNode
|
||||
self.is_leaf = False
|
||||
|
||||
def insert_many(self, words: list[str]) -> None:
|
||||
|
||||
Reference in New Issue
Block a user