I passed the testcases, with some changes but i don’t understand why did my code overflow in the first place
class Solution {
public:
int combinationSum4(vector<int>& nums, int k)
{
//dp[i] no of ways to get sum i
long long int dp[100000];
dp[0]=1;
for(long long int i=1;i<=k;i++){dp[i]=0;}
for(long long int i=1;i<=k;i++){
//cout<<dp[i];
for(auto x:nums){
if(i>=x){
cout<<dp[i]<<"\n";
dp[i]=dp[i]+dp[i-x];
}
}
}
return dp[k];
}
};