NeetCode #401LC-549MediumTreesNC Algo100
← Back to All Problems#401 · #549 · Binary Tree Longest Consecutive Sequence II(二叉树最长连续序列 II)
📌 Problem Statement & Constraints
Given the root of a binary tree, return the length of the longest consecutive path. Unlike the basic version, this path may be either increasing or decreasing, and it may turn at most once (a node can have one increasing and one decreasing branch). Constraints: the number of nodes is in
[1, 3 * 10^4].🔒
Sign In to Unlock Full Solutions for All 973 Problems
Sign in to access step-by-step logic, benchmark Python3 code, complexity breakdown, and offline export!