Driver code
let grid = [ [ 25 , 5 , 25 , 25 , 25 , 25 ] , [ 25 , 1 , 1 , 5 , 12 , 25 ] , [ 25 , 1 , 12 , 0 , 15 , 25 ] , [ 22 , 1 , 11 , 2 , 19 , 15 ] , [ 25 , 2 , 2 , 1 , 12 , 15 ] , [ 25 , 9 , 10 , 1 , 11 , 25 ] , [ 25 , 25 , 25 , 25 , 25 , 25 ] ] ; let K = 17 ; let M = grid . length ; let N = grid [ 0 ] . length ; let X = 2 , Y = 3 ; if ( findPath ( grid , X , Y , M , N , K ) ) document . write ( " " ) ; else document . write ( " " ) ;