i
and j
, for encoded1
and encoded2
respectively.product_encoded
to store the result.i
and j
are within the bounds of their respective arrays:
a. Calculate the product of the current values pointed by i
and j
.
b. Determine the minimum frequency from the current segments.
c. Subtract the minimum frequency from the frequencies of the current segments.
d. If the frequency of a segment becomes zero, move the corresponding pointer forward.
e. If the last segment in product_encoded
has the same value as the current product, add the minimum frequency to it.
f. Otherwise, append a new segment with the current product and minimum frequency to product_encoded
.product_encoded
.