educative.io

Educative

Could you explain what happens in this line of code exactly?

product[i] = product[i] * right


Type your question above this line.

Course: https://www.educative.io/collection/5642554087309312/5634727314718720
Lesson: https://www.educative.io/collection/page/5642554087309312/5634727314718720/5639868793225216

@amir

Here we are multiplying product with the most right value in the array. In each iteration there will be a decrement with the right index which is specified in the loop. At initial point product is [1, 0, 0, 0], after each iteration the calculated product of the array values will be stored in it.

1 Like

thank you for your explanation