NeetCode #465LC-979MediumTrees
← Back to All Problems#465 · #979 · Distribute Coins in Binary Tree(在二叉树中分配硬币)
📌 Problem Statement & Constraints
Given the root of a binary tree with
n nodes, each node has node.val coins, and there are n coins in total. In one move you may move one coin between adjacent nodes. Return the minimum number of moves to make every node have exactly one coin. Constraints: the number of nodes is in [1, 100], 0 <= Node.val <= n.🔒
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!