Round 1
Questions:
I was given a grid of size (n-1) * (n) where n is the number of columns. The value at each index of the matrix could either be 0 or 1.
I am allowed to move top down or bottom right of the matrix. I need to reach the position (n-2, n).
We need to return true
if the number of 1s encountered on the path is the same as the number of 0s.
Follow up: Now you're allowed to move in any 4-directions (left, right, top, bottom) in the matrix. Return true if the number of 1s encountered is the same as the number of 0s.
Candidate's Approach
I was able to solve the initial question using DFS by exploring all the paths and counting 0s and 1s from the source to the destination.
Interviewer's Feedback
No feedback provided.