The template should be modified to return ‘ans’. Currently, it shows void in the signature.
Specifically for the C++ version of the Backtracing template: At line 5, a confusing variable counter is introduced
int counter = 0;
That is never referenced/used. I think you meant to define the initial value of the answer variable. This is what is written for the template in the other programming languages.