question–>
https://practice.geeksforgeeks.org/problems/multiply-two-strings/1#
code–>
string multiplyStrings(string s1, string s2) {
bool isnega=false;
if(s1[0]=='-' and s2[0]!='-'){
isnega=true;
s1=s1.substr(1);
}
else if(s1[0]!='-' and s2[0]=='-'){
isnega=true;
s2=s2.substr(1);
}
else{
s1 = s1.substr(1);
s2 = s2.substr(1);
}
int *ans=new int[s1.length()+s2.length()];
for(int i=0;i<=s1.length()+s2.length();i++)ans[i]=0;
for(int i=s1.length()-1;i>=0;i--){
for(int j=s2.length()-1;j>=0;j--){
int mul=((s1[i]-'0')*(s2[j]-'0'))+ans[i+j+1];
ans[i+j+1]=(mul%10);
ans[i+j]+=(mul/10);
}
}
string x;
for(int i=0;i<(s1.length()+s2.length());i++){
if(x.length()!=0 || ans[i]!=0){
x.push_back(ans[i]+'0');
}
}
if(isnega) x = "-"+x;
return x;
}
not passing all test cases help