Question: 5 3 4 4 2 2 3 7 2 6 6 3 4 q 3 zay 7 Compute the distance between the positions of the

5344223726634 q3zay7
Compute the distance between the positions of the first and last zero element in the given array. For example, if the array is 301049506 your algorithm should yield 7-1=6.
If the array contains a single zero, return 0. If it doesn't contain any zeroes, return a negative value.
Numbers.java
NumbersTester.java
public class Numbers
T
public static int zeroesDistance(double[] values)
{
int firstPos =0;
int lastPos = values. length -1 ;
boolean found = false;
while (firstPos values. length && !found)
Y** Your code goes here */
return lastPos - firstPos;
}
}
 5344223726634 q3zay7 Compute the distance between the positions of the first

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!