Visa Inc. Interview Question

Problem with DFS inside a matrix