Loading section...
Duplicate Skipping: The Detail That Breaks Candidates
Concepts: pyDuplicateSkipping, pyDedup
Duplicate handling is where most candidates lose points on two-pointer problems. The logic is subtle: you need to skip values you have already used as the fixed element (to avoid duplicate triplets), AND skip values you have already used as the left/right pair (to avoid duplicate triplets within the same fixed element). Getting either wrong produces duplicates in the output. The key insight: you skip AFTER processing, not before. After finding a valid triplet, advance left past all copies of its current value, and advance right past all copies of its current value. For the outer loop, skip the current fixed element if it equals the PREVIOUS one (not the next one). Skipping based on the next element would miss valid triplets. The Subtle Bug The difference: with nums = [-1, -1, 0, 1], the tr