I have used DP to solve the problem and my logic seems correct but I don’t know where the error is in my code due to which the test case is not passing
#include
using namespace std;
void fillArray(int arr[],int maxVal,int n){
int a[maxVal+1];
a[0] = 0;
a[1] = 2;
a[2] = 3;
for(int i=3;i<=maxVal;i++){
a[i] = a[i-1]+a[i-2];
}
for(int i=0;i<n;i++){
cout<<"#"<<arr[i]<<"\t:\t"<<a[arr[i]]<<endl;
}
return;
}
int main() {
int n,max=0,arr[45];
cin>>n;
for(int i=0;i<n;i++){
cin>>arr[i];
max = (arr[i]>max) ? arr[i] : max;
}
fillArray(arr,max,n);
return 0;
}