items[i] is the part number of the i-th part; parts with the same number are identical. Customer orders are given in orders: the j-th customer wants orders[j] parts.
Can every order be filled at once, given that:
- the j-th customer gets exactly orders[j] parts;
- all parts in one order share the same part number;
- each part goes to at most one customer?
Leftover parts may stay in the warehouse. Return True if this is possible and False otherwise.items=[7, 7, 7, 2, 2, 5], orders=[2, 3] → True
The order for 3 takes the three 7s, the order for 2 takes the two 2s.
items=[1, 1, 2, 2, 3, 3], orders=[3] → False
No kind has three pieces, and an order cannot mix kinds.
items=[4, 4, 4, 4, 4], orders=[2, 2] → True
items) ≤ 10⁵items[i] ≤ 1000orders) ≤ 10orders[j] ≤ 10⁵items=[7, 7, 7, 2, 2, 5], orders=[2, 3]
True
Run checks the first 3 tests in your browser. Submit checks all 65 tests on the server, hidden ones included.