Reach your HR

0

0 votes
Hard
Problem

An MxN matrix is given. The starting point is C - Candidate(index 0,0). The destination is h - your HR(index M-1,N-1). You've to reach him with the shortest path inorder to secure your position as a Software Developer. You've to follow only the path marked as 'y'. The paths that are marked as 'n' are your competitors and if they find you, you'll lose your job. You can traverse up, down, left and right.

The black spots in the diagram are your competitors.

Escape from them and get your dream job !

 

Sample Input :

4 4

c n n n
y y n y
n y n n
y y y h

Sample Output : 6

Explanation :

 c       
 y  y    
    y     
    y  y  h

Reach from c to h.

 

 

Time Limit: 5
Memory Limit: 256
Source Limit:
Editor Image

?