Microsoft Interview Question
Software Engineer / DevelopersThis is just a thought( i may be wrong).....
Rough idea =>
shoot(x , y){
if(y not in range of shooting distance){
decrement bullets of x;
return;
}
if(y is on the line of shoot){
hit y;
decrement power of y based on power of shooting;
decrement bullets of x;
}
else{
miss y;
decrement bullets of x;
}
return;
}
Take an Array of M,N and initialize to 1's if shoot(x,y) then make the corresponding x,y to 0' and return true.... if you find 0 then return false.
- Vamsi December 05, 2007