r / c [terminology]
Terminology¶
Usage¶
- Use for row and column coordinates in matrix and grid algorithms.
- They may be loop variables, current coordinates, or recursive coordinates.
- Prefer them over
rowandcolwhen the scope is compact. - Do not use
rsimultaneously as both "row" and "right pointer" in the same scope.
m, n = len(mat), len(mat[0])
dist = [[-1] * n for _ in range(m)] # -1 means "not processed yet"
q = deque()
for r in range(m):
for c in range(n):
if mat[r][c] == 0:
dist[r][c] = 0
q.append((r, c))
# ...
See 542. 01 Matrix.