Skip to content
concept

Duplicate Control

Reasoning that prevents, removes, detects, or safely tolerates repeated values or repeated candidate results as a central correctness obligation.

Tagged articles

Duplicate Control articles

21 articles in this tag.

Close-up of hands coding on a laptop, showcasing software development in action.
intermediate
10 min read

3Sum

A reliable 3Sum solution comes from turning a cubic search into a sequence of sorted two-sum scans—and proving why each pointer move is safe.

View solution
Visual abstraction of neural networks in AI technology, featuring data flow and algorithms.
advanced
13 min read

4Sum

Four choices suggest an O(n^4) search. Sorting changes the last two choices into a controlled walk.

View solution
Overhead view of a MacBook laptop on a dark desk, showcasing modern technology and minimalism.
intermediate
12 min read

Combination Sum II

The hard part is not finding combinations that add to the target. It is finding them once while respecting the physical number of occurrences in the input.

View solution
Dark-themed laptop setup with a red glowing keyboard and code on screen, ideal for tech enthusiasts.
intermediate
10 min read

Combination Sum

Treat this as an enumeration problem, not a permutation problem. Sort the candidates, keep combinations in nondecreasing order, recurse from the same index…

View solution
3D rendered abstract brain concept with neural network.
intermediate
11 min read

Combinations

The duplicate-ordering trap is the whole problem: [1, 2] and [2, 1] represent one selection, not two. Build every path in increasing order, and the…

View solution
Laptop with a blank screen placed on a brown velvet chair in a bright room.
advanced
11 min read

Distinct Subsequences

Repeated characters create the trap: different selections from s can produce the same visible text in t, and the problem still counts those selections…

View solution
Lush green water plants float in a serene pool at Meise Botanical Garden, Belgium.
expert
14 min read

Median of Two Sorted Arrays

Merging is the obvious solution. It is also disqualified by the runtime requirement. The useful reframe is to search for a cut, not for a value: place…

View solution
Black computer cables splayed on a vibrant yellow surface, highlighting technology connection themes.
advanced
11 min read

Next Permutation

The reliable way to solve Next Permutation is to stop thinking in four memorized steps. Read the suffix, identify where it is already maximal, then make…

View solution
A stack of traditional terracotta pots in a Vietnamese pottery workshop, illustrating local craftsmanship.
intermediate
12 min read

Permutations II

When nums = [1, 1, 2], ordinary permutation backtracking treats the two 1 values as different input positions. That creates duplicate value sequences.

View solution
A breathtaking view of a desert landscape with a vibrant sunset illuminating the horizon.
intermediate
12 min read

Subsets II

The duplicate bug comes from treating equal input positions as different decisions. Sort first, then skip equal candidates only when they are siblings at…

View solution