Stackoverflow error


I might be doing wrong with the base case but unable to think beyond this solution. Need Help!!

refer to this here

Well Thank you Again!! Btw I’m confused… why my code is wrong… will you please help to correct that as well

ans += sub(arr, sum, idx+1);

will solve the stack overflow but your code is giving wrong answer