Question: Write a method called rangeBetweenZeroe s that takes as a parameter an ArrayList of integers and returns the number of indexes apart the two farthest
Write a method called rangeBetweenZeroe s that takes as a parameter an ArrayList of integers and returns the number of indexes apart the two farthest occurrences of the number 0 are. For example, if the list stores the values [7, 2, 0, 0, 4, 0, 9, 0, 6, 4, 8] when the method is called, it should return 6 , because the occurrences of 0 that are farthest apart are at indexes 2 and 7, and the range 2 through 7 has six elements. If only one 0 occurs in the list, your method should return 1. If no 0 s occur, your method should return 0.
Step by Step Solution
3.31 Rating (163 Votes )
There are 3 Steps involved in it
public static int rangeBetweenZeroes ArrayList list ... View full answer
Get step-by-step solutions from verified subject matter experts
