Skip to content

Instantly share code, notes, and snippets.

View TOuhrouche's full-sized avatar

TOuhrouche

View GitHub Profile
// 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 {