Distinct Elements

Medium
2
1
5.8% Acceptance

Task

  1. Create a function distinct(array, length of array) . This distinct() will take two arguments - a dynamic uint type array and length of the array.
  2. The distinct() will return the number of distinct elements in an array. For Example - If array =[4, 2, 3, 4] then distinct() will return 3. If array =[1, 1, 1] then distinct() will return 1.

Note - Function will be public.

You can do this :)