def postorderTraversal(self, root): if not root: return  stack = [root] res =  while stack: cur = stack.pop() if cur.left: stack.append(cur.left) if cur.right: stack.append(cur.right) res.append(cur.val) return res[::-1]
Thank you for your comment. May I ask if the quadratic runtime comes from "res = [cur.val] + res"? Thank you very much.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.