Open
Description
int the recursive function
`int rec(const vector& A, int B, const vector& C, int pos)
{
if(B == 0) {
return 0;}
int n = A.size();
int i, count = 0;
for(i = 0; i < n; i++) {
if(A[i] >= C[pos]) {
break;
}
count++;
}
if(pos == 0 && A[0] == 0)
{the above if statement should also include "B!=1" so that if an array(A[1]={0}) is passed as an input with B as 1 and C as 5, it would not return 0
count--;
}
int result = count * pow(n, B - 1);
if(i == n || A[i] != C[pos]) {
return result;
}
return result + rec(A, B - 1, C, pos + 1);
}
`
Metadata
Metadata
Assignees
Labels
No labels