As reported: Microsoft SDE IC3 phone screen (US, Oct 2025), question 2 of 2: a combination-sum style problem — fill the
'?'placeholders of a work schedule.
A work schedule pattern has one character per day: a digit (hours already fixed for that day) or '?' (not decided yet). Given workHours (the total hours for the week) and dayHours (the maximum hours on any undecided day), return all schedules obtained by replacing every '?' with a digit from 0 to dayHours so that the digits sum to workHours. Return them in ascending order.
Example 1
pattern = "89??233", workHours = 40, dayHours = 8
-> ["8978233","8987233"]
The fixed days add up to 25, so the two '?' must add up to 15 with each at most 8.
Example 2
pattern = "1234?5?7", workHours = 25, dayHours = 5
-> ["12340537","12341527","12342517","12343507"]
Constraints: 1 ≤ pattern.length ≤ 10; at most 7 '?'; 0 ≤ dayHours ≤ 9; 0 ≤ workHours ≤ 90; the answer has at most 10^4 schedules.
Code runner format: one JSON value per line: pattern, workHours, dayHours. Implement findSchedules(pattern, workHours, dayHours); the harness sorts your list and prints it.