Introduction to Backtracking
Backtracking is “Recursion + Pass by Reference + Undoing the change after function call”
Pseudo Code:
void backtrackingFunction(...params){
if(invalid) return;
if(valid){
ans.push(value);
return;
}
--- Do the operations ---
Must pass the params by reference which are being updated
backtrackingFunction(...updatedParams);
--- Undo the operations ---
}