You are on page 1of 1

public static int findZero(int[] A, int pos) //parameters given by the question { for(int i = pos; i < A.

length; i++) { if(A[i] == 0) return i; } return -1; }

public class ArrayManipulation { public int findZero (int array[], int pos) { for (; pos < array.length; pos++) if (array[pos] == 0) return pos; return -1; } public int[] setZeros (int array[]) { int start = findZero(array, 0); int end = findZero(array, start + 1); for (; start < end; start++) array[start] = 0; return array; } }

..

You might also like