totalTime
to 0.left
and right
to 0.colors
string using the right
pointer.
a. For each group of balloons with the same color, calculate currTotal
(sum of neededTime
for the group) and currMax
(maximum neededTime
in the group).
b. Increment right
until the color of the balloon at right
is different from that at left
.currTotal - currMax
to totalTime
.left
to the current right
to start processing the next group.colors
string is reached.totalTime
.