Skip to content

nr / nc [terminology]

Terminology

Usage

  • Use for the next or neighboring row and column derived from r and c.
  • They are appropriate when paired with dr and dc.
  • Here, n means "next" or "neighbor," not a dimension.
for dr, dc in ((-1, 0), (1, 0), (0, -1), (0, 1)):
    nr, nc = r + dr, c + dc
    if 0 <= nr < m and 0 <= nc < n:
        dfs(nr, nc)

See 200. Number of Islands.