Unit 2 Session 1 (Click for link to problem statements)
Understand what the interviewer is asking for by using test cases and questions about the problem.
Plan the solution with appropriate visualizations and pseudocode.
General Idea: Loop through each product, and make a list of any products with quantity below the threshold.
1) If products is empty, return an empty list
2) Restock list starts empty
3) For each product and quantity:
a) If quantity < threshold, add to restock list
4) Return restock list
def get_items_to_restock(products, restock_threshold):
if not products:
return []
restock_list = []
for product, quantity in products.items():
if quantity < restock_threshold:
restock_list.append(product)
return restock_list