Question 8

Suppose you are given a puzzle that is represented as a matrix with 0s and 1s, where a 0 indicates you’re allowed to move into that position and 1 means you’re not allowed to move in that position. Write a function that given a start position and an end position, returns a boolean value indicating if there exists a path from start to end. you are only allowed to move up, left, right and down. Diagonal movement is not allowed.

Example #1

Input

0 0 1 0 1

0 0 0 0 0

0 1 1 1 1

0 1 1 0 0

start: 4,1

end 0,3

Output – true

Example #2

Input

0 0 1 1 1

0 1 0 0 0

1 1 1 1 1

0 0 0 0 1

start: 0,0

end: 1,2

Output – false

[advanced_iframe securitykey=”undefined” src=”https://code.kodnest.com/” width=”100%” height=”600″]

×