File tree 1 file changed +16
-2
lines changed
1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change 1
1
# Time: O(n)
2
- # Space: O(n )
2
+ # Space: O(h )
3
3
4
4
# Serialization is the process of converting a data structure or
5
5
# object into a sequence of bits so that it can be stored in a file
@@ -67,5 +67,19 @@ def deserializeHelper():
67
67
node .left = deserializeHelper ()
68
68
node .right = deserializeHelper ()
69
69
return node
70
- vals = iter (data .split ())
70
+ def isplit (source , sep ):
71
+ sepsize = len (sep )
72
+ start = 0
73
+ while True :
74
+ idx = source .find (sep , start )
75
+ if idx == - 1 :
76
+ yield source [start :]
77
+ return
78
+ yield source [start :idx ]
79
+ start = idx + sepsize
80
+ vals = iter (isplit (data , ' ' ))
71
81
return deserializeHelper ()
82
+
83
+ # Your Codec object will be instantiated and called as such:
84
+ # codec = Codec()
85
+ # codec.deserialize(codec.serialize(root))
You can’t perform that action at this time.
0 commit comments