Why case [3,2,2] is expected to be 1? (close and with my solution)

Oh... it is longest consecutive sequence so only for the increasing number.
so 3>2 isn't count as consecutive sequence.
Here's my Python solution.def longestConsecutive(self, root): if not root: return 0 def trace(root, now_len, preval, sign): if now_len == 1: if prevalroot.val == 1: now_len += 1 sign = '+' else: sign = '*' else: # more than length 1 if prevalroot.val == 1 and sign == '+': now_len += 1 else: now_len = 1 sign = '*' if now_len > self.ans: self.ans = now_len if root.left: trace(root.left, now_len, root.val, sign) if root.right: trace(root.right, now_len, root.val, sign) self.ans = 1 if root.left: trace(root.left, 1, root.val, '*') if root.right: trace(root.right, 1, root.val, '*') return self.ans