Interview Bootcamp
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!
Faraz Ahmed

Faraz Ahmed

· a month ago

it would be better if you include N-Queens Problem in Backtracking, as it contains of multiple backtracking variations, also the moving of queens makes sense, wrong step , the queen backtracks and choose a different positon!! thats pure backtracking there

Show 1 reply
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 2 replies
V

viniciuslopeslps

· 2 years ago

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

Show 1 reply

Reading Progress

0%


Vote for new content