Write a method called rangeBetweenZeroe s that takes as a parameter an ArrayList of integers and returns

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 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.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: