Microsoft Interview Question

Similar to Rotten Oranges problem