I try to determine the runtime complexity of the following code. I came up with T(n) = n * T(n-1) + n
where T(0) = 1
but not sure if it's correct and how to solve it.
private void myFunction(int[] nums, int startIndex, int target) {
if (target == 0) {
// do something
}
if (target <= 0 || start > nums.length) {
return;
}
for (int i = startIndex; i < nums.length; i++) {
myFunction(nums, i+1, target-nums[i]);
}
}
myFunction(nums, 0, target);