[Solved] What this function do? [closed]


This function counts all distinct elements in an array.

The outer loop loops over all array elements. The inner loop loops over the array until the element of the outer loop. The count is incremented if there is no preceding element which is similar to the current element.

For instance, given the array

[1, 2, 3, 4, 3, 1, 5]

The value of c will be

1, 2, 3, 4, 4, 4, 5

so the result is 5, which is the number of distinct elements in the array.

2

solved What this function do? [closed]