This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. return the number of bundle that can be assembled from a list of products | |
// 2. Bundle is a tree of products with multiple nested levels | |
// 3. return the count without knowing the number of tree levels (N Stages). | |
int getBundleCount(List<Product> products, Product bundle) { | |
Map<String, int> productsListLeaves = {}; | |
for (Product product in products) { | |
if (productsListLeaves[product.name] == null) { | |
productsListLeaves[product.name] = 1; | |
} else { |