@@ -0,0 +1,773 @@
+# Definition for a binary tree node.%0A# class TreeNode(object):%0A#     def __init__(self, x):%0A#         self.val = x%0A#         self.left = None%0A#         self.right = None%0A%0Aclass Solution(object):%0A    def dfs(self,target,root,curlen):%0A        if not root:%0A            return curlen%0A        # if not consectutive, reset%0A        if root.val!=target:%0A            curlen=0%0A            %0A        curlen+=1%0A        left=self.dfs(root.val+1,root.left,curlen)%0A        right=self.dfs(root.val+1,root.right,curlen)%0A        # get the max from the subtree%0A        return max(curlen,left,right)%0A        %0A    def longestConsecutive(self, root):%0A        %22%22%22%0A        :type root: TreeNode%0A        :rtype: int%0A        %22%22%22%0A        if not root:return 0%0A        return self.dfs(-1,root,0)%0A        

[298. Binary Tree Longest Consecutive Sequence][Accepted]committed by Victor