MCPcopy Index your code
hub / github.com/HuberTRoy/leetCode / insert

Method insert

Tree/CompleteBinaryTreeInserter.py:103–126  ·  view source on GitHub ↗

:type v: int :rtype: int

(self, v)

Source from the content-addressed store, hash-verified

101 self.insert(i)
102
103 def insert(self, v):
104 """
105 :type v: int
106 :rtype: int
107 """
108
109 node = self.current_node[-1]
110 if not node.left:
111 node.left = TreeNode(v)
112 parent = node
113 self._next_node.append(node.left)
114
115 elif not node.right:
116 node.right = TreeNode(v)
117 parent = node
118 self._next_node.append(node.right)
119 self.current_node.pop()
120
121 if not self.current_node:
122 self._next_node.reverse()
123 self.current_node = self._next_node
124 self._next_node = []
125
126 return parent.val
127
128 def get_root(self):
129 """

Callers 1

get_init_nodesMethod · 0.95

Calls 3

TreeNodeClass · 0.85
reverseMethod · 0.80
popMethod · 0.45

Tested by

no test coverage detected