Grokking 75: Top Coding Interview Questions
Vote

0% completed

Introduction to Backtracking Pattern

You are given candidate numbers and a target. Find every combination that adds up to the target, where each candidate may be used any number of times.

candidates [2, 3, 6, 7]   target 7   gives [2, 2, 3] and [7]

The Subsets pattern would build every possible combination and then throw away the ones that miss the target. That is correct and wasteful. Once a partial combination has reached 8, no amount of adding will bring it back to 7, and yet the Subsets approach keeps extending it.

.....

.....

.....

Like the course? Get enrolled and start learning!
V

viniciuslopeslps

· 2 years ago

Would be nice a video explaining the backtrack pattern and maybe an easy exercise too

Avanish Vyas

Avanish Vyas

· 2 years ago

It would be great if you could add a general template for each coding pattern that we can re-use in all the problems of that type. Also, it would be better

Show 1 reply