jobs, where jobs[i] is the kind of the i-th job. The jobs must be done strictly in the given order. Each day you either do the next job or take a day off.
Once a job of some kind is done, the next job of the same kind may only be done after at least rest days have passed.
Return the smallest number of days needed to finish all the jobs.jobs=[7, 3, 7, 7], rest=2 → 7
Day 1: 7, day 2: 3, day 3: rest, day 4: 7, days 5–6: rest, day 7: 7.
jobs=[1, 2, 3, 1], rest=2 → 4
Two days already pass between the two jobs of kind 1, so no rest is needed.
jobs=[5, 5], rest=1 → 3
jobs=[7, 3, 7, 7], rest=2
7
Run checks the first 3 tests in your browser. Submit checks all 97 tests on the server, hidden ones included.