MLE in result ,in o(n*m) space


My solution is giving mle. in o(n*m) space. getting partial points


Try using bool for marking the visited coordinates…


try using map for storing visited coordinates


mark visited[i][j] just after pushing into queue to avoid MLE. If not you would push same (i,j) pair many times into queue in bfs and it causes MLE


thanks man! was stuck. The reason makes sense!