Distribute Coins in Binary Tree | Leetcode 979 | Interview Question for DSA

Опубликовано: 16 Июль 2026
на канале: Moody Vish
558
2

Problem link : https://leetcode.com/problems/distrib...


You are given the root of a binary tree with n nodes where each node in the tree has node.val coins. There are n coins in total throughout the whole tree.

In one move, we may choose two adjacent nodes and move one coin from one node to another. A move may be from parent to child, or from child to parent.

Return the minimum number of moves required to make every node have exactly one coin.

Watch related videos:
▶ Find Valid Matrix Given Row and Column Sums | Leetcode 1605 | Interview Question for DSA -    • Find Valid Matrix Given Row and Column Sum...  
▶ Lucky Numbers in a Matrix | Leetcode 1380 | Interview Question for DSA -    • Lucky Numbers in a Matrix | Leetcode 1380 ...  
▶ Lexicographical Numbers | Leetcode 386 | Interview Question for DSA -    • Lexicographical Numbers | Leetcode 386 | I...