Bazaarvoice Interview Question
Senior Software Development EngineersTeam: Platform and Products
Country: United States
Interview Type: In-Person
I think this is very intuitive . We have to go through all the elements and then increment each element by 1 until we either reach an element which is less than or equal to eight or the first element if we reach the first element we have to shift the whole array right and add 1 in starting.
int[] incerement(int a[]){
for(int i = a.length-1;i>0;i--){
if(a[i]<=8)
{
a[i]++;
break;
}
else
{
a[i]=0
}
}
if(i==0&&a[i]==0)
{
b=new int[a.length+1];
b[0]=1;
return b;
}
return a;
}
I don't understand your question. Can you please describe in detail?
- Anonymous January 16, 2014