NeetCode #429LC-2641MediumTrees
← Back to All Problems#429 · #2641 · Cousins in Binary Tree II(二叉树的堂兄弟节点 II)
📌 Problem Statement & Constraints
Given the root of a binary tree, replace each node's value with the sum of all values on the same level that are not its cousins' -- precisely, with
level_sum - sibling_sum, where sibling_sum is the sum of the node and its sibling. The root becomes 0. Constraints: the number of nodes is in [1, 10^5], 1 <= Node.val <= 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!