Daily challenge for 2026-05-31
516. Leaf Node Value Sum
Given a binary tree represented as an adjacency list, calculate the sum of all values belonging to 'leaf' nodes. A leaf node is defined as a node that has no outgoing edges to children. The tree is directed from parent to child. You are provided with a dictionary tree where keys are node IDs (integers) and values are lists of child node IDs, and a dictionary values where keys are node IDs and values are their corresponding integer values.
Example:Input: tree = {0: [1, 2], 1: [], 2: []}, values = {0: 10, 1: 5, 2: 7}Output: 12
Run this challenge interactively in Python or JavaScript when the app loads.