max_picked
to 0, left
to 0, and an empty hash map basket
.right
pointer.fruits[right]
to the basket
and increment its count.basket
contains more than two types of fruits:
a. Decrease the count of fruits[left]
in the basket
.
b. If the count becomes 0, remove fruits[left]
from the basket
.
c. Increment left
.max_picked
with the maximum of its current value and the size of the window (right - left + 1
).max_picked
after the loop ends.