Skip to content

prefix / suffix [terminology]

Terminology

Usage

  • Use for accumulations strictly before or after the current position.
  • They communicate direction and excluded boundaries.
  • Keep the full names because abbreviations such as pref and suff save little and are less balanced.
  • Do not rename them to total; they may be multiplicative accumulators.
prefix = 1

for i in range(n):
    res[i] = prefix
    prefix *= nums[i]