← Sprinklr questions

Minimum moves in matrix using BFS

Filed under Sprinklr

The question

Given an integer matrix of NxM dimensions, in one move you can go from (i, j) to either (i + m[i][j], j) or (i, j + m[i][j]). Starting at (1,1), find the minimum number of moves to reach (N, M), or print -1 if not possible without jumping outside the matrix.

No write-up yet. Related questions below have one.

Related Sprinklr questions

Collected from public candidate posts and coding forums. Updated Nov 2026.