Graph Theory37 sections · 1633 units
Open in Course

LeetCode 886 Possible Bipartition - Index Handling

One-indexed vs zero-indexed

People are numbered 11 to nn, not 00 to n1n-1. You have two options: create arrays of size n+1n+1 and use indices 11 to nn (index 00 stays unused), or subtract 11 from all person numbers to make them 00-indexed, then use arrays of size nn.

Both work. The first is simpler to think about. Remember your loop bounds: iterate from 11 to nn, not 00 to n1n-1. Off-by-one errors are common here.