Math Fundamentals18 sections · 814 units
Open in Course

Combinations - Building Strategy

Choose or skip pattern

How do you build combinations without duplicates? If you pick number 11, then the next number must be 22 or greater. If you pick 22, the next must be 33 or greater. This gives you a natural ordering.

You use backtracking with a start index. At each step, you try all numbers from your current position onward. Once you add a number to your combination, you recurse with the next position as the new start.

Base case: when your combination has kk numbers, you found a valid combination. Add it to the result and backtrack.