cur_penalty
, min_penalty
, and earliest_hour
to 0.customers
string:
a. If the character is 'Y', decrement cur_penalty
by 1.
b. If the character is 'N', increment cur_penalty
by 1.
c. If cur_penalty
is less than min_penalty
, update min_penalty
to cur_penalty
and set earliest_hour
to the current index plus 1.earliest_hour
after completing the iteration over the string.