Backtracking pattern
Combination Sum
Given an array of distinct candidate numbers and a target, return all unique combinations of candidates that sum to the target, where each candidate may be reused an unlimited number of times. Watch it run step by step, then write your own pseudocode and get it checked by AI.
- LeetCode 39
- Medium
- 1 approach
Sign in with Google or GitHub and you land straight on this page. DSA comes with the all labs plan and every ChaiCode batch.
BacktrackingLeetCode 39
Medium
The approach
- 01 Backtracking · non-decreasing picks with overshoot pruning O(n^(T/min))O(T/min) space
What you will learn
- How to read Combination Sum and spot the backtracking pattern in it
- Backtracking · non-decreasing picks with overshoot pruning: O(n^(T/min)) time, O(T/min) space
- The pseudocode for each approach, its line lit as the animation runs
- Practice: write your own pseudocode and get it checked
More Backtracking
See Combination Sum run, step by step
Sign in and this page opens on the animation, with all 8 Backtracking problems beside it.
DSA comes with the all labs plan and every ChaiCode batch.