please check and tell if my code is more efficient than explained of not.
private static int[] allindex(int[] arr, int si, int data, int count) {
if(si == arr.length)
return new int[count];
if(arr[si] == data) {
count++;
}
int[] arr2 = allindex(arr, si+1, data, count);
if(count >=1)
arr2[count-1] = si;
return arr2;
}