educative.io

Confusion with max element

A reader asked us the following question:

Here, arr[maxId] is stored as the multiplier. Whereas, arr[i] is stored as the remainder. For example in the array, [1, 2, 3, 4, 5, 6, 7, 8, 9], the maxElem is 10" - how is the max element 10 here? Isn’t it 9?

Hi,

This is Maisam Shah from Educative. Thank you for reaching out to us!

In response to your query, the “maxElem” variable does not store the maximum element but stores any element that is greater than the maximum element in the array, which in our case will be “10”.

Thank you for your valuable feedback! If you have any further queries or concerns, please feel free to get in touch again.

Best Regards,
Maisam Shah | Developer Advocate
Educative