Count Shipment Schedules
Problem statement
A binary string stock represents a shipment schedule. A 1 marks a day with a shipment already scheduled, and a 0 marks an empty day.
Choose exactly k different empty days and change their zeros to ones. Count the different resulting schedules. Do not change any other position.
Return the exact count, without a modulus. If fewer than k empty days exist, return 0. Choosing zero days gives one schedule: the original string.
For this exercise, assume an empty schedule is allowed. It has one result when k = 0 and no results otherwise. The number of days is stock.length.
Function
countShipmentSchedules(stock: String, k: int) → longExamples
Example 1
stock = "1010100"k = 3return = 4The reported seven-day schedule has four empty days, at zero-based positions 1, 3, 5, 6. Choose any three. The four possible sets are {1,3,5}, {1,3,6}, {1,5,6}, and {3,5,6}.
Example 2
stock = "010"k = 1return = 2Choose position 0 to get 110, or position 2 to get 011. These are the only two choices.
Constraints
- For this exercise, assume 0 <= stock.length <= 60.
- stock contains only '0' and '1'.
- For this exercise, assume 0 <= k <= 60.
- The exact count fits a signed 64-bit integer.