Skip to content

rev [terminology]

Terminology

Usage

  • Use for a reversed representation being constructed.
  • It is more semantic than ans in reversal algorithms.
  • It can represent reversed digits, bits, characters, or links when the context is clear.
rev = 0

for _ in range(32):
    rev = (rev << 1) | (n & 1)
    n >>= 1