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

Method _deserialize

Tree/SerializeAndDeserializeBinaryTree.py:187–212  ·  view source on GitHub ↗
(roots, nodes)

Source from the content-addressed store, hash-verified

185 leaves = [root]
186
187 def _deserialize(roots, nodes):
188 _next = []
189 for i in roots:
190 if not i:
191 continue
192
193 if nodes:
194 val = nodes.pop(0)
195 if val == ' None':
196 val = 'null'
197 else:
198 val = int(val)
199
200 i.left = TreeNode(val)
201 _next.append(i.left)
202
203 if nodes:
204 val = nodes.pop(0)
205 if val == ' None':
206 val = 'null'
207 else:
208 val = int(val)
209
210 i.right = TreeNode(val)
211 _next.append(i.right)
212 return _next
213 base = _deserialize(leaves, data[:length])
214 data = data[length:]
215 length *= 2

Callers

nothing calls this directly

Calls 2

TreeNodeClass · 0.85
popMethod · 0.45

Tested by

no test coverage detected