Which SKUs Need Reordering?

Easy ⏱ 8 min 79% acceptance ★★★★☆ 4.3
Each product dict has sku, stock, reorder_level, on_order (units already ordered). Write to_reorder(products) returning the sorted list of SKUs where stock + on_order is at or below the reorder level — pending orders must count, or you double-order.

Examples

Example 1
Input
to_reorder([{'sku': 'A', 'stock': 2, 'reorder_level': 5, 'on_order': 0}, {'sku': 'B', 'stock': 1, 'reorder_level': 5, 'on_order': 10}])
Output
['A']
Explanation

B's incoming 10 units cover it.

Constraints

  • Include on_order in the check.
  • Sorted SKU list.

Topics

Business Logicinventory

Companies

WalmartFlipkartDMart Tech

Hints

Hint 1

stock + on_order <= reorder_level.

Hint 2

Comprehension then sorted().

Loading the Python runtime… Run executes your code and shows printed output; Submit checks your function against this problem's examples.