As reported: Goldman Sachs Associate Superday, round 2 (meant to be SE practices / SDLC; India, 2025): a binary tree whose node values are coin counts (positive or zero); make every node hold exactly 1 coin and return the minimum total number of moves. The statement was kept vague on purpose; it was a variation of Distribute Coins in Binary Tree.
A binary tree has n nodes and n coins in total; node.val is the coins at that node. In one move you can move one coin between two adjacent nodes (parent ↔ child). Return the minimum number of moves so that every node has exactly one coin.
This is LeetCode 979 — Distribute Coins in Binary Tree.
Example 1
root = [3,0,0]
-> 2
Example 2
root = [0,3,0]
-> 3
Example 3
root = [1,0,2]
-> 2
Constraints: 1 ≤ n ≤ 100; 0 ≤ node.val ≤ n; the values sum to n.
Code runner format: one JSON value per line: root (LeetCode's test-case format). Implement distributeCoins(root); the harness prints the result as JSON.