Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
breadth-first search solution in Clear category for Can You Pass? by 1-more
def can_pass(matrix, first, second):
N,M = len(matrix), len(matrix[0])
stack= [first]
visited= set()
while stack:
x,y= stack.pop(0)
for dx,dy in ((-1,0),(1,0),(0,-1),(0,1)):
if 0<=x+dx
Nov. 17, 2015
Comments: