Problem Description
Loading...
Problem Analysis
Note that the question asks for the minimum number of rest days
so we need to keep the number of days with $a[i]==0$ as small as possible
Scan from front to back
if $a[i]==3$
then if $a[i-1]==1$, set $a[i]=2$
if $a[i-1]==2$, set $a[i]=1$
If a 3 appears at the very start of the loop, it needs no consideration
because no matter how many 3s there are, they can all be combined into busy days
with no effect on the answer
If $a[i]==a[i-1]$
then update $a[i]$ to 0
cpp
| |