used [terminology]
Terminology
Usage
- Use for choices or resources currently unavailable.
- Common examples include used colors, indices, characters, or cells in the current branch.
- Unlike
visited, used may represent a temporary constraint rather than permanent traversal state.
colors = [0] * n # 0 means "uncolored".
for garden in range(n):
used = set() # Colors already used by colored neighbors.
for nei in graph[garden]:
if colors[nei] != 0:
used.add(colors[nei])
for color in range(1, 5):
if color not in used:
colors[garden] = color
break
See 1042. Flower Planting With No Adjacent.