Skip to content

issue with solve() fucntion #3

@shashwat5013

Description

@shashwat5013

int solve(int b){
num.clear();
while(b>0){
num.push_back(b%10);
b/=10;
}
reverse(num.begin(), num.end());
/// Stored all the digits of b in num for simplicity

memset(DP, -1, sizeof(DP));
int res = call(0, 0, 0);
cout<<res<<endl;
return res;

}

modified code for memset

int solve(int a,int b){
memset(dp,-1,sizeof(dp));
vector digitA;
getDigit(a-1,digitA);
int ans1=getData(digitA.size()-1,0,1,digitA);
vector digitB;
getDigit(b,digitB);
int ans2=getData(digitB.size()-1,0,1,digitB);
return ans2-ans1;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions