When to reorder a part
Purchasing wants the stock level at which a part should be reordered, so it arrives before the shelf runs dry.
- Cover the daily usage for the whole lead time, then add the safety stock on top.
- Any negative input is bad data — treat it as zero.
reorderPoint(dailyUse: int, leadDays: int, safety: int) → int
C++ needs a compiler and Drill does not host one yet, so this page is the reference rather than an exercise: the problem, worked examples, and the solution in full. To type it out, the same problem runs in Python.
Where you start
int reorderPoint(int dailyUse, int leadDays, int safety) {
}
Worked examples
| Call | Result |
|---|---|
reorderPoint(10, 3, 5) | 35 |
reorderPoint(0, 7, 20) | 20 |
reorderPoint(12, 0, 0) | 0 |
reorderPoint(-5, 3, 10) | 10 |
Hint
dailyUse × leadDays + safety, with each input floored at zero first.
Reference solution in C++
int reorderPoint(int dailyUse, int leadDays, int safety) {
return std::max(0, dailyUse) * std::max(0, leadDays) + std::max(0, safety);
}