"test with custom input "giving right answer.But after submitting its giving wrong answer.what the duck?


#1

int k=0;

void ans(vector fib,int x)
{
if(x==0)
return;
else
{
int i=0;
while(fib[i]<=x)
{
i++;
}
int val=x-fib[i-1];
k++;
ans(fib,val);
}
}
int Solution::fibsum(int A)
{
vector fib={1,1};
int i=1;//set of fibonacci numbers
while(fib[i]<=A)
{
fib.push_back(fib[i]+fib[i-1]);
i++;
}
ans(fib,A);
return k;
}