educative.io

Educative

Does this improve the speed?

Hi there
Arrays.fill(count, 0)
What does this do in kotlin?

Hi @Ego,

Array.fill() receive an array and value to be assigned on every index of the array. Since count is an array variable in this example, this Array.fill(count, 0) will set all elements of the count array to 0. And yes, it works faster than assigning values element by element in an array.

Let me know if you still have any queries on this.
Thanks.