Getting error in test case 5 and test case 6

#include
using namespace std;
#define mod 1000000007
int main() {
int n;
cin>>n;
int dp[n+1];
dp[0]=1;
dp[1]=1;
for(int i=2;i<n+1;i++){
dp[i]=(dp[i-1]+dp[i-2])%mod;
}
cout<<dp[n];
return 0;
}
Getting error in test cases 5 and 6.

Hey @pranjal123
You have to solve it without memory.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

#include using namespace std; int main() { int n; cin>>n; int c; int a=1; int b=1; for(int i=1;i<n;i++){ c=a+b; a=b; b=c; } cout<<b; return 0; }

I solved using o(1) memory but it still showing wrong answer.

@pranjal123
You have not taken the mod. This is the reason you answer is turning out to be wrong. It is explicitly mentioned that you have to take modulus wrt 1e9 + 7.