###257. Binary Tree Paths 题目: 难度: Easy Tag : tree, DFS 类似的题目是Path Sum Ⅱ 第一眼看起来不像easy题目,然后堵了一下自己写的Path Sum Ⅱ自己的解答 同一种花样 ``` class Solution: # @param {TreeNode} root # @return {string[]} def binaryTreePaths(self, root): if root == None: return [] result = [] self.auxTreePaths(root,result,"") return result def auxTreePaths(self,root,result,curStr): if root == None: return curStr += str(root.val) if root.left == None and root.right == None: result.append(curStr) if root.left: self.auxTreePaths(root.left,result,curStr + "->") if root.right: self.auxTreePaths(root.right,result,curStr + "->") ```