educative.io

Why initiate the result array to all 1s?

I don’t think we need to do this, all default values works the same as they will be overwritten anyway.

Hi @jack1 ,

This is Fatimah Abdullah from Educative. Thank you for reaching out to us!

In response to your question, you are correct! We do not need to initialize the array elements with 1 value as the temp variable is already fulfilling that purpose. The temp variable is initialized zero as well. Thank you for pointing out this redundant code. I have updated the lesson and fixed this issue.

Best Regards,

Fatimah Abdullah | Developer Advocate
Educative

1 Like