我做了一道108. Convert Sorted Array to Binary Search Tree, with Python 3
run code总是显示AttributeError
去playground debug,看到了报错信息里,一个把结果打印出来的辅助函数treeNodeToString是这样的:
def treeNodeToString(root):
if not root:
return "[]"
output = ""
queue = [root]
current = 0
while current != len(queue):
node = queue[current]
current = current + 1
if not node:
output += "null, "
continue
output += str(node.val) + ", "
queue.append(node.left)
queue.append(node.right)
return "[" + output[:-2] + "]"
反正我是没有看明白……
后来我自己写了一个类似功能的函数,终于在playground中调试成功了……
然而回到problem界面我又伤心了,,我要怎么修改会插入代码的code snippet呢?呵呵呵……
桑心……
现在就想弄明白到底咋回事儿……
后续:AttributeError是犯了一个很挫很小白的错误引起的,虽然答案已经被接受了,但我依然看不懂这个auxiliary function......