Category leaf counts
Your task
A storefront keeps its category catalog as a tree. Entry i of children lists the indexes of the direct subcategories of category i, in the order a merchandiser arranged them, and category 0 is the catalog root. A category with no subcategories of its own is a leaf, which is where products actually hang. The navigation bar shows the root's direct subcategories, and each one needs a badge counting the leaf categories underneath it. Return one count per direct subcategory of the root, in the order those subcategories appear in the root's own entry. A subcategory with nothing beneath it is itself a leaf and counts as 1. Indexes can point anywhere in the list, so a subcategory is not guaranteed to sit after its parent. Return an empty list when children is empty or when the root has no subcategories.
Examples
taxonomy_branch_leaf_counts(children: list[list[int]]) -> list[int]taxonomy_branch_leaf_counts([[1, 2], [3, 4], [], [], []])[2, 1]taxonomy_branch_leaf_counts([[2, 1], [], [3, 4], [], []])[2, 1]taxonomy_branch_leaf_counts([[1], [2], [3], []])[1]