package CodingBlocks;
public class AllIndices {
public static void main(String[] args) {
int[] arr = {3,8,1,8,8};
int[] ans =allIndices(arr, 0 , 8 , 0);
System.out.println(ans);
}
public static int[] allIndices(int[] arr, int si, int item,int count)
{
int[] indices=null;
if(si==arr.length)
{
int[] base = new int[count];
return base;
}
if (arr[si]==item) {
indices = allIndices(arr,si+1,item,count+1);
}
else
{
indices = allIndices(arr,si+1,item,count);
}
if (arr[si]==item)
{
indices[count]=si;
}
return indices;
}
}