Twitter Interview Question: If there are N lanes and K ca... |

Interview Question

Software Engineer Interview

If there are N lanes and K cars in each lane and Cars[i][j

 ] = (position of car, length of car), and if a frog has to cross the road in one straight jump (vertically down), not encountering any car, write a function to determine if he will be able to do it. You are given a frozen state of the road.

Interview Answer

1 Answer


You can consider the the N*N matrix and put the cell value 0 for the car position now the question is jumping from first row to last row can be solved using back track or dynamic programming very similar to robot path finding problem

Gautam on 17-Mar-2014

Add Answers or Comments

To comment on this, Sign In or Sign Up.