JAVA numDistinctElements returns the number of distinct el

JAVA

/**
* numDistinctElements returns the number of distinct elements in a given array of doubles.
*
* Some examples:
* numDistinctElements(new double[] { }) is 0
* numDistinctElements(new double[] { 1, -4, -7, 7, 8, 11 }) is 6
* numDistinctElements(new double[] { -7, -4, -7, 3, 8, 8 }) is 4
*/

Code Below:

public static int numDistinctElements (double[] list) {
return 0;
}

Solution

As  numDistinctElements is counting number of unique digit,

as in numDistinctElements(new double[] { 1, -4, -7, 7, 8, 11 }) there is 6 number of unique digits,

as in numDistinctElements(new double[] { -7, -4, -7, 3, 8, 8 }) there is 4 number of uniquedigits,

in case of public static int numDistinctElements (double[] list) {
return 0;
}

The return 0 is the Exit status of the program.

In short, the definition of Exit status of a program is as follows: It is a small number returned by a child process (or callee) (in this case, your program), to the parent process (or caller) (in this case, the shell you will be running it in (most likely, the command prompt)), when it has finished executing a specific procedure or delegated task.

JAVA /** * numDistinctElements returns the number of distinct elements in a given array of doubles. * * Some examples: * numDistinctElements(new double[] { }) i

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site