Backtracking explores choices while keeping enough state to reject impossible partial answers. A branch can select a parcel, place a camera, or enter the next cell of a word route. Before recursing, apply the choice. After the branch returns, restore every part of the state that the choice changed. A missing restoration can make unrelated branches inherit one another's constraints.
Repeated input values need careful interpretation. Equal-weight parcels remain distinct when selections refer to parcel indices. Repeated badge letters are indistinguishable when you return unique strings. Those are different counting contracts. Sorting helps prune equivalent choices, but only when the task treats them as equivalent. Begin with a binary selection tree, then handle duplicate outputs, remaining capacity, and board constraints. The final task combines several simultaneous conflict sets.
weights = [2,3,5,5], target = 10
valid index sets: [2,3], [0,1,2], [0,1,3]
count = 3
The two weight-5 parcels have different indices.
Selecting one of the equal parcels can produce a distinct index subset.