Available question text
Count the number of nonnegative integer pairs (pens, pencils) satisfying cost1*pens + cost2*pencils ≤ total — i.e., count integer solutions to a linear inequality. This is solved by iterating one item count up to total/cost and summing how many of the other fit (O(total/min(cost))).
Related questions
Continue with questions that share topics or the same question type.
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
No company association
Leetcode 2240. Number of Ways to Buy Pens and Pencils
Reported date not specified · 0 source reports
Source snapshot: Nov 12, 2026
View source