id
int64
1
3.58k
problem_description
stringlengths
516
21.8k
instruction
int64
0
3
solution_c
dict
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "#include <string>\nclass Solution {\npublic:\n string multiply(string num1, string num2) {\n \n if(num1[0] == '0' || num2[0] == '0'){\n return \"0\";\n }\n string ans = \"\";\n vector <string> answer;\n int cnt = 0;\n\n for(int i=num1.size()-1;...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n string multiply(string num1, string num2) {\n if (num1 == \"0\" || num2 == \"0\") {\n return \"0\";\n }\n\n string res = \"\";\n\n for (int i = num1.length() - 1; i >= 0; i--) {\n int carry = 0;\n string tmp_res;\n\...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n string multiply(string num1, string num2) {\n vector<string>nums;\n\n if(num1.size() < num2.size()) swap(num1, num2);\n\n if(num2 == \"0\") return \"0\";\n\n for(int i=num2.size() - 1; i >=0; --i){\n string temp = string(num2.size() - i ...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n string multiply(string num1, string num2) {\n vector<string>nums;\n\n if(num1.size() < num2.size()) swap(num1, num2);\n\n if(num2 == \"0\") return \"0\";\n\n for(int i=num2.size() - 1; i >=0; --i){\n string temp = string(num2.size() - i ...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n string multiply(string num1, string num2) {\n int n1=num1.size(), n2=num2.size(), i, j;\n vector<int> A;\n for(i=0; i<n1; i++) {\n int a=num1[n1-1-i]-'0', c=0;\n vector<int> t;\n for(j=0; j<n2 || c; j++) {\n ...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n string singledigitmult(string num1, char c) {\n string output = \"\";\n int n = num1.size();\n int carry = 0;\n \n for(int i = n-1; i >= 0; i--) {\n int val = (num1[i] - '0') * (c - '0') + carry;\n carry = val / 10;\n ...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\n string addStrings(string nums1, string nums2) {\n \n string res=\"\";\n int co=0;\n for(int i=nums1.size()-1,j=nums2.size()-1;i>=0 || j>=0;--i,--j){\n int n1=0;\n int n2=0;\n if(j>=0)\n n2=nums2[j]-'0';\n ...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\n string addStrings(string nums1, string nums2) {\n \n string res=\"\";\n int co=0;\n for(int i=nums1.size()-1,j=nums2.size()-1;i>=0 || j>=0;--i,--j){\n int n1=0;\n int n2=0;\n if(j>=0)\n n2=nums2[j]-'0';\n ...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n string multiply(string num1, string num2) {\n if (num1.size() == 1 || num2.size() == 1) {\n return mult(num1, num2);\n }\n int m = max(num1.size(), num2.size())/2;\n string a, b, c, d;\n if (m >= num1.size()) {\n a = \"...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n\n string multiply(string &num1, char c){\n string s;\n num1 = '0' +num1;\n int carry = 0, n = num1.size();\n for(int i = n-1;i>=0;i--){\n int val = (c-'0') * (num1[i]-'0') + carry;\n s += val%10 + '0';\n carry = val...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\nstring mul(int x, string num1, int ct){\n int carry=0;\n string ans=\"\";\n for(int i=0; i<num1.length(); i++){\n int rl=(num1[num1.length()-1-i]-'0')*x+carry;\n // cout<<rl<<endl;\n ans+=((rl%10)+48);\n carry=rl/10;\n }\n if(carry>0)ans...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n\n string multiply(string num1, char c){\n string s;\n num1 = '0' +num1;\n int carry = 0, n = num1.size();\n for(int i = n-1;i>=0;i--){\n int val = (c-'0') * (num1[i]-'0') + carry;\n s += val%10 + '0';\n carry = val/...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n string update_sum(string s1, string s2) {\n \n string t1 = s1.length()<= s2.length() ? s1:s2;\n string t2;\n if(t1 == s1)\n t2 = s2;\n else\n t2 = s1;\n int i= t1.length()-1,j = t2.length()-1;\n int carry=0;\n ...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n string multiply_a_number(string s, int num){\n if(num ==0) return \"0\";\n int carry = 0;\n string ans = \"\";\n for(int i =0; i < s.size(); ++i){\n int idx = s.size() - 1 -i;\n int n = (s[idx] - '0') * num + carry;\n ...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n string add(string a, string b) {\n int ptr = 0;\n int a_len = a.length(), b_len = b.length();\n int carry = 0;\n string res = \"\";\n while (ptr < min(b_len, a_len)) {\n int sum = carry + int(a[a_len - ptr - 1] - '0') + int(b[b_le...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n string multiply2(string s1, char s2, int dec)\n {\n cout << s1 << \":\" << s2 << endl;\n int rem = 0, i=s1.length()-1;\n string ans;\n while(i>=0)\n {\n int temp = (s1[i] - 48) * (s2 - 48) + rem;\n ans.push_back((cha...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n\n void mul(string s1, string s2,vector<vector<int>>&v){\n vector<int>v1;\n int len = s1.length(), mul =0 , c=0,r=0, len1 = s2.length();\n reverse(s1.begin(), s1.end());\n reverse(s2.begin(),s2.end());\n for(int j=0; j<len1; j++){\n ...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n string multiply(string s1, string s2) {\n vector<int> n1, n2;\n for(int i = 0; i < s1.size(); ++i) n1.push_back(s1[s1.size() - i - 1] - '0');\n for(int i = 0; i < s2.size(); ++i) n2.push_back(s2[s2.size() - i - 1] - '0');\n\n vector<vector<int>> ro...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n string addTwoStrings(string num1, string num2) {\n string n1 = num1.size() >= num2.size() ? num1 : num2;\n string n2 = num1.size() < num2.size() ? num1 : num2;\n\n reverse(n1.begin(), n1.end());\n reverse(n2.begin(), n2.end());\n\n while (n2...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n void reverse(string &res)\n {\n int n=res.size();\n int i=0,j=n-1;\n while(i<j)\n {\n swap(res[i],res[j]);\n i++;j--;\n }\n }\n string helpmul(string s,int a)\n {\n int n=s.length();\n string r...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n void reverse(string &res)\n {\n int n=res.size();\n int i=0,j=n-1;\n while(i<j)\n {\n swap(res[i],res[j]);\n i++;j--;\n }\n }\n string helpmul(string s,int a)\n {\n int n=s.length();\n string r...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\nprivate:\n int atoi(char c){\n return c-'0';\n }\n\n string add(string a, string b){\n string ans = \"\";\n reverse(a.begin(), a.end());\n reverse(b.begin(), b.end());\n\n int n = a.size(), m = b.size();\n\n int carry=0, i=0;\n for...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n\n string multiply(string &num1, char c){\n string s;\n num1 = '0' +num1;\n int carry = 0, n = num1.size();\n for(int i = n-1;i>=0;i--){\n int val = (c-'0') * (num1[i]-'0') + carry;\n s += val%10 + '0';\n carry = val...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n string multi(string num1,char ch,string ans){\n\n int n = num1.size();\n\n int i=n-1;\n int carry = 0;\n while(i>=0){\n int a = num1[i]-'0';\n int b = ch-'0';\n\n int c = a*b + carry;\n int dig = c%10;\n ...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "/*\nQues to ask:\n - Can number contain leading 0?\n - Can number be negative?\n - Can number empty i.e \"\"?\n\nSol:\n=> Elementary maths : [TIME - O(N+M) SPACE - O(N+M)]\n-> N : no of digits in num1\n-> M : no of digits in num2\n - Check if num1 or num2 is '0' or not, if it is then return 0\n...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n\n string add(string str1, string str2){\n int n = str1.size(), m = str2.size();\n int maxi = max(n, m);\n int carry = 0;\n string res = \"\";\n for(int i = 0; i < maxi; i++){\n int num1 = 0, num2 = 0;\n if(i < n){\n ...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n string multiply(string num1, string num2) {\n if(num1==\"0\"||num2==\"0\") return \"0\";\n vector<vector<int>> prods;\n reverse(num1.begin(),num1.end());\n reverse(num2.begin(),num2.end());\n for(int i=0;i<num2.size();i++){\n int ...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n string multiply(string num1, string num2) {\n if(num1==\"0\"||num2==\"0\") return \"0\";\n vector<vector<int>> prods;\n reverse(num1.begin(),num1.end());\n reverse(num2.begin(),num2.end());\n for(int i=0;i<num2.size();i++){\n int ...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n\n std::string\n multC( std::string num, char c ) {\n if( c == '0' ) {\n return \"0\";\n }\n\n int ci = c - '0';\n\n std::string ans;\n int carry = 0;\n\n for( auto i = num.rbegin(); i != num.rend(); i++ ) {\n ...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n\n string addStrings(string num1, string num2) {\n int n = num1.size();\n int m = num2.size();\n \n if (n < m) {\n swap(num1, num2);\n swap(n, m);\n }\n\n num2 = string(n - m, '0') + num2;\n \n int c...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n string intToString(unsigned long long n){\n string str=\"\";\n while(n){\n char ch=n%10+'0';\n str+=ch;\n n=n/10;\n }\n reverse(str.begin(),str.end());\n return str;\n }\n string addStrings(string a, st...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n string intToString(unsigned long long n){\n string str=\"\";\n while(n){\n char ch=n%10+'0';\n str+=ch;\n n=n/10;\n }\n reverse(str.begin(),str.end());\n return str;\n }\n string addStrings(string a, st...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\nprivate:\n // Calculate the sum of all of the results from multiplyOneDigit.\n string sumResults(vector<vector<int>>& results) {\n // Initialize answer as a number from results.\n vector<int> answer = results.back();\n vector<int> newAnswer;\n results.pop...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\nprivate:\n // Calculate the sum of all of the results from multiplyOneDigit.\n string sumResults(vector<vector<int>>& results) {\n // Initialize answer as a number from results.\n vector<int> answer = results.back();\n vector<int> newAnswer;\n results.pop...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\n\nprivate:\n\n // Calculate the sum of all of the results from multiplyOneDigit.\n\n string sumResults(vector<vector<int>>& results) {\n\n // Initialize answer as a number from results.\n\n vector<int> answer = results.back();\n\n vector<int> newAnswer;\n\n ...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\nprivate:\n // Calculate the sum of all of the results from multiplyOneDigit.\n string sumResults(vector<vector<int>>& results) {\n // Initialize answer as a number from results.\n vector<int> answer = results.back();\n vector<int> newAnswer;\n results.pop...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n string multiply(string num1, string num2) {\n reverse(num1.begin(), num1.end());\n reverse(num2.begin(), num2.end());\n vector<string> temp;\n for(int i = 0; i < num1.size(); i++){\n string curr;\n for(int j = 0; j < i; j++){\...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n string multiply(string num1, string num2) {\n int n=num1.size();\n int m=num2.size();\n if(num1==\"0\"||num2==\"0\") return \"0\";\n vector<vector<int>> v(m);\n int ct=0;\n for(int i=0;i<m;i++){\n for(int k=0;k<ct;k++) v[i]....
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "void reversestring(string &a){\n int left=0,right=a.size()-1;\n while(left<right){\n char t;\n t=a[left];\n a[left]=a[right];\n a[right]=t;\n left++;\n right--;\n } \n}\nstring addbignum(string a,string b){\n reversest...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n string multiply(string num1, string num2) {\n string ans=\"\";\n for(int i = 0 ; i< 202; i++){\n ans = ans + '0';\n }\n char carry = '0';\n int p = 201;\n int s = 0;\n for (int i = num2.size() - 1; i >= 0; i--) {\n ...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n string multiply(string num1, string num2) {\n string ans=\"\";\n for(int i = 0 ; i< 202; i++){\n ans = ans + '0';\n }\n char carry = '0';\n int p = 201;\n\n for (int i = num2.size() - 1; i >= 0; i--) {\n int z = 201 - ...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n string add(string s1, string s2){\n reverse(s1.begin(), s1.end());\n reverse(s2.begin(), s2.end());\n int idx = 0;\n int carry = 0;\n string res = \"\";\n while(idx < min(s1.size(), s2.size())){\n int x = s1[idx] - '0';\n ...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\n string singMultiply (string num1, int num2, int padding){\n int size = num1.size(); string singProduct;\n stack <int> digits;\n int carry {0};\n for (int i = size - 1; i >= 0; i--){\n int tempProduct = (num1[i] - '0') * num2 + carry;\n ...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\n string singMultiply (string num1, int num2, int padding){\n int size = num1.size(); string singProduct;\n stack <int> digits;\n int carry {0};\n for (int i = size - 1; i >= 0; i--){\n int tempProduct = (num1[i] - '0') * num2 + carry;\n ...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n string multiply(string num1, string num2) {\n if(num1.size()+num2.size()<18){\n return to_string(stoll(num1)*stoll(num2));\n }\n //split the num1 and num2;\n //num1 and num2 should have the same digit length\n //M=(a+b)(c+d)\n ...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\nconst int M = 1e9+7;\nconst int N = 1e6;\n#define bg begin()\n#define ed end()\n#define rbg rbegin()\n#define red rend()\n#define pb push_back\n#define pf push_front\n#define fi first\n#define se second\n#define vc vector\n#define pr pair\n#define sz(x) (int)x.size()\n#define nl ...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n \n string reverse(string str)\n {\n string result = \"\";\n int strSize = str.size();\n for(int i = strSize - 1; i >= 0; i--)\n {\n result += str[i];\n }\n return result;\n }\n\n string sumStrings(string s1, str...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n string sum(vector<vector<int>>&res){\n vector<int>ans=res.back();\n res.pop_back();\n vector<int>cur;\n for(auto it:res){\n cur.clear();\n int carry=0;\n for(int i=0;i<ans.size() || i<it.size();i++){\n ...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\nvoid fillZeros(string& s1, string& s2)\n{\n //s1 je manji\n\n int n1=s1.length();\n int n2=s2.length();\n\n string s=\"\";\n\n for(int i=0;i<n2-n1;i++)\n s+='0';\n\n s+=s1;\n\n s1=s;\n\n}\n\nstring add(string s1, string s2)\n{\n string sol=\"\";\n ...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n string multiply(string num1, string num2) {\n if (num1 == \"0\" || num2 == \"0\") return \"0\";\n \n int s1 = num1.size(); int s2 = num2.size();\n vector<int> n1(s1); vector<int> n2(s2);\n\n for (int i = 0; i<s1; i++) {\n n1[i] = ...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n int ctoi(char c) {\n switch (c) {\n case '0':\n return 0;\n case '1':\n return 1;\n case '2':\n return 2;\n case '3':\n return 3;\n case '4':\n ...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n string multiply(string num1, string num2) {\n\n if(num1 == \"0\" || num2 == \"0\") return \"0\";\n\n int n1 = num1.size();\n int n2 = num2.size();\n\n map<int, vector<int>> m1;\n int base = -1;\n\n for(int i=n2-1;i>=0;i--) {\n ...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n string add(string num1, string num2) {\n int sum = 0, carry = 0, curr = 0;\n string res = \"\";\n int len1 = num1.length(), len2 = num2.length();\n while (len1 - 1 - curr >= 0 && len2 - 1 - curr >= 0) {\n int dig1 = int(num1[len1 - 1 - c...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n string add(string num1, string num2) {\n int sum = 0, carry = 0, curr = 0;\n string res = \"\";\n int len1 = num1.length(), len2 = num2.length();\n while (len1 - 1 - curr >= 0 && len2 - 1 - curr >= 0) {\n int dig1 = int(num1[len1 - 1 - c...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n string add(string A, string B) {\n int n = A.size(), m = B.size();\n vector<int> pos(max(n,m)+1, 0);\n for(int i=n-1, j=m-1, k=pos.size()-1; (i>=0 || j>=0) && k>=1; --i, --j, --k) {\n int a = i>=0? (A[i]-'0') : 0;\n int b = j>=0? (B[...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n string add(string A, string B) {\n int n = A.size(), m = B.size();\n vector<int> pos(max(n,m)+1, 0);\n for(int i=n-1, j=m-1, k=pos.size()-1; (i>=0 || j>=0) && k>=1; --i, --j, --k) {\n int a = i>=0? (A[i]-'0') : 0;\n int b = j>=0? (B[...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "/*\n 5\n017\n428\n 6\n*/\n\n\nclass Solution {\npublic:\n string multiply(const string& num1, const string& num2) {\n const string* p1 = &num1;\n const string* p2 = &num2;\n if(num1.size() < num2.size()){\n p1 = &num2;\n p2 = &num1;\n }\n if(*p...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\nprivate:\n int StoI(char s) {\n return (s - '0');\n }\n\n string addStrings(const string& n1, const string& n2) {\n int carry = 0;\n int i = n1.size() - 1, j = n2.size() - 1;\n stringstream result;\n \n while (i >= 0 || j >= 0 || carry) {...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n string add(const string &s1, const string &s2) {\n int n1 = s1.length();\n int n2 = s2.length();\n \n int i = n1 - 1, j = n2 - 1;\n int carry = 0;\n stack<int> ss;\n\n // Add both strings\n while (i >= 0 || j >= 0 || car...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "// class Solution {\n// public:\n// int n1,n2;\n// // vector<int> ans(10000,0);\n// vector<int> ans = vector<int>(10000, 0);\n// void f(vector<int>& vec1,char c,int j){\n// int d = c-'0';\n// int i=10000-j;\n// int carry = 0;\n// for(int j=n2-1;j>=0;j--){\n//...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n string multiply(string num1, string num2) {\n\n if(num1 == \"0\" || num2 == \"0\") return \"0\";\n\n int n1 = num1.size();\n int n2 = num2.size();\n\n map<int, vector<int>> m1;\n int base = -1;\n\n for(int i=n2-1;i>=0;i--) {\n ...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n string multiply(string num1, string num2) {\n if(num1 == \"0\" || num2 == \"0\") return \"0\";\n string& shorter = num1.size() < num2.size() ? num1 : num2;\n string& longer = num1.size() < num2.size() ? num2 : num1;\n string res = \"0\";\n s...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n string multiply(string num1, string num2) {\n vector<vector<int>> m;\n if(num1.size()<num2.size()){\n string s=\"\";\n s=num1;\n num1=num2;\n num2=s;\n }\n //cout<<num1<<\" \"<<num2<<endl;\n int ...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n string multiply(string num1, string num2) {\n vector<vector<int>> m;\n if(num1.size()<num2.size()){\n string s=\"\";\n s=num1;\n num1=num2;\n num2=s;\n }\n //cout<<num1<<\" \"<<num2<<endl;\n int ...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n string multiply(string num1, string num2) {\n if(num1==\"0\" || num2==\"0\") return \"0\";\n string finalans=\"\";\n if(num1.length()>=num2.length())\n {\n for(int i=num2.length()-1;i>=0;i--)\n {\n int carry=0;\...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n string multiply(string num1, string num2) {\n \n if(num1.size() > num2.size()) {\n swap(num1, num2);\n }\n\n reverse(num1.begin(), num1.end());\n reverse(num2.begin(), num2.end());\n cout<<num1<<\" \"<<num2<<endl;\n ...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n string multiply(string num1, string num2) {\n if(num1 == \"0\" || num2 == \"0\") return \"0\" ;\n string sum = \"\" ;\n int carry = 0 ;\n int k = 1 ;\n for(int i = num2.size()-1 ; i>=0 ; i--){\n string num = \"\" ;\n ...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\nprivate:\n string getFirstN(string s, int n) {\n return s.substr(0, n);\n }\n\n string removeFirstN(string s, int n) {\n return s.substr(n, s.length());\n }\n\n // write a c++ function to add two integers represented as strings without converting\n string a...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\nprivate:\n // returns first n chars\n string getFirstN(string s, int n) {\n return s.substr(0, n);\n }\n\n // returns string excluding first n chars\n string removeFirstN(string s, int n) {\n return s.substr(n, s.length());\n }\n\n // returns num1 >= num...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\nprivate:\n string getFirstN(string s, int n) {\n return s.substr(0, n);\n }\n\n string removeFirstN(string s, int n) {\n return s.substr(n, s.length());\n }\n\n // returns str1 < str2\n bool compareStr(string num1, string num2) {\n // check if one is...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\nprivate:\n // returns first n chars\n string getFirstN(string s, int n) {\n return s.substr(0, n);\n }\n\n // returns string excluding first n chars\n string removeFirstN(string s, int n) {\n return s.substr(n, s.length());\n }\n\n // returns num1 >= num...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\nprivate:\n // returns first n chars\n string getFirstN(string s, int n) {\n return s.substr(0, n);\n }\n\n // returns string excluding first n chars\n string removeFirstN(string s, int n) {\n return s.substr(n, s.length());\n }\n\n // returns num1 >= num...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\n/*\nYou must not convert the inputs to integer directly.\n \n 25 *\n 4\ncarry.2 0\n 100\n\n 25\n 12\ncarry1 50\n 250\n\n1. Multiply reverse order\n2. Summation\n*/\npublic:\n string multiply(string num1, string num2) {\...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n string multiply(string num1, string num2) {\n if(num2 == \"0\" || num1 == \"0\") return \"0\";\n vector<string> a;\n string s;\n for(int i = num2.size() - 1; i >= 0; i--){\n int n = 0;\n for(int j = num1.size() - 1; j >= 0; j--...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n string addStrings(string num1, string num2) {\n string result(max(num1.size() , num2.size()) + 1, '0');\n int i = num1.size() - 1, carry = 0 , j = num2.size() - 1;\n int k = result.size() - 1;\n while(i >= 0 || j >= 0 || carry != 0){\n i...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n/*\n 858\n 45\n 4290 carry 0 \n 34220\n 38510\n\n*/\n string multiply(string num1, string num2) {\n if (num1 == \"0\" || num2 == \"0\") {\n return \"0\";\n }\n if (num1.length() < num2.length()) {\n string temp = num1;\n...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n std::string multiply(std::string num1, std::string num2) {\n if (num1 == \"0\" || num2 == \"0\") return \"0\"; // Edge case where one of the numbers is zero\n\n int n1 = num1.size();\n int n2 = num2.size();\n\n vector<string> ans;\n\n for(i...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n string multiply(string num1, string num2) {\n\n if (num1.size() > num2.size())\n return multiply(num2, num1);\n\n if (num1 == \"0\" || num2 == \"0\")\n return \"0\";\n\n reverse(num1.begin(), num1.end());\n reverse(num2.begin(...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n string adder(string ans, string temp) {\n // 2sum of strings logic\n int n= ans.length()-1;\n int m= temp.length()-1;\n if(m>n) return adder(temp, ans);\n if(m == -1) return ans;\n int carry = 0;\n while(m>=0) {\n in...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n string adder(string ans, string temp) {\n // 2sum of strings logic\n int n= ans.length()-1;\n int m= temp.length()-1;\n if(m>n) return adder(temp, ans);\n if(m == 0) return ans; //this optimize when one is empty\n int carry = 0;\n ...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n string adder(string ans, string temp) {\n // 2sum of strings logic\n int n= ans.length()-1;\n int m= temp.length()-1;\n if(m>n) return adder(temp, ans);\n if(m == 0) return ans; //this optimize when one is empty\n int carry = 0;\n ...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n string adder(string ans, string temp) {\n // 2sum of strings logic\n int n= ans.length()-1;\n int m= temp.length()-1;\n if(m>n) return adder(temp, ans);\n if(m == 0) return ans; //this optimize when one is empty\n int carry = 0;\n ...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "\nclass Solution {\n public:\n string multiply(string num1, string num2) {\n int len1 = num1.length();\n int len2 = num2.length();\n\n if (len1 == 1) {\n if (num1[0] == '1')\n return num2;\n if (num1[0] == '0')\n return \"0\";\n ...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "\nclass Solution {\n public:\n string multiply(string num1, string num2) {\n int len1 = num1.length();\n int len2 = num2.length();\n\n if (len1 == 1) {\n if (num1[0] == '1')\n return num2;\n if (num1[0] == '0')\n return \"0\";\n ...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\nstring add(const string &numStr1, const string &numStr2) {\n // Ensure numStr1 is the longer of the two strings\n string n1 = numStr1.size() >= numStr2.size() ? numStr1 : numStr2;\n string n2 = numStr1.size() < numStr2.size() ? numStr1 : numStr2;\n \n // Reverse th...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n string num_mul_str(char& num, string my_str) {\n string reverse_str = my_str;\n reverse(reverse_str.begin(), reverse_str.end());\n\n string ans = \"\";\n int carry = 0;\n int digit = 0;\n\n for (int i = 0; i < my_str.size(); i++) {\n ...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n\n string f(string a,string b)\n {\n if(a.size()<b.size())swap(a,b);\n reverse(a.begin(),a.end());\n reverse(b.begin(),b.end());\n while(b.size()<a.size())\n {\n b+='0';\n }\n int c=0;\n string ans=\"\";\n ...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n\n string f(string a,string b)\n {\n if(a.size()<b.size())swap(a,b);\n reverse(a.begin(),a.end());\n reverse(b.begin(),b.end());\n while(b.size()<a.size())\n {\n b+='0';\n }\n int c=0;\n string ans=\"\";\n ...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n string multiply(string num1, string num2) {\n \n if(num1 == \"0\" || num2 == \"0\")\n return \"0\";\n \n if(num2.size() > num1.size())\n swap(num1, num2);\n \n int ptrOne = num1.size() - 1;\n int ptrTwo = ...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n string longmultiply( char a , string num2 ){\n int x = int(a-'0');\n int i = num2.size()-1;\n int cy = 0;\n string ans =\"\";\n while( i >= 0 ){\n int mul = x * int(num2[i]-'0');\n mul += cy;\n cy = mul/10;\n...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n string longmultiply( char a , string num2 ){\n int x = int(a-'0');\n int i = num2.size()-1;\n int cy = 0;\n string ans =\"\";\n while( i >= 0 ){\n int mul = x * int(num2[i]-'0');\n mul += cy;\n cy = mul/10;\n...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n string find(vector<string> s)\n {\n int sizee=0;\n string res=\"\";\n for(int i=0;i<s.size();i++)\n {\n sizee=max(sizee,static_cast<int>(s[i].size()));\n }\n int sum=0;\n int carry=0;\n for(int i=0;i<sizee;...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n string adder(string ans, string temp) {\n // 2sum of strings logic\n int n= ans.length()-1;\n int m= temp.length()-1;\n if(m>n) return adder(temp, ans);\n if(m == 0) return ans; //this optimize when one is empty\n int carry = 0;\n ...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n string adder(string ans, string temp) {\n // 2sum of strings logic\n int n= ans.length()-1;\n int m= temp.length()-1;\n if(m>n) return adder(temp, ans);\n if(m == 0) return ans; //this optimize when one is empty\n int carry = 0;\n ...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n string multiply(string num1, string num2) {\n string up = \"\";\n string down = \"\";\n if (num1.length() > num2.length()) {\n up = num1;\n down = num2;\n } else {\n up = num2;\n down = num1;\n }\n...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "\nclass Solution {\npublic:\n string multiply(string num1, string num2) {\n\n if (num1.size() < num2.size()) {\n swap(num1, num2);\n }\n if(num1[0]=='0' || num2[0]=='0'){\n return \"0\";\n }\n int n1 = num1.size();\n int n2 = num2.size();\n...
43
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as strings, return the product of <code>num1</code> and <code>num2</code>, also represented as a string.</p> <p><strong>Note:</strong>&nbsp;You must not use any built-in BigInteger library or convert the inputs to integer directly.<...
3
{ "code": "class Solution {\npublic:\n string solvem(string a, char b, int m, int ind){\n int carry = 0;\n int val = b-'0';\n string ans = \"\";\n for(int i=m-1;i>=0;i--){\n int tmp = (val*(a[i]-'0')) + carry;\n carry = tmp/10;\n ans = to_string(tmp%10)+...
44
<p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>&#39;?&#39;</code> and <code>&#39;*&#39;</code> where:</p> <ul> <li><code>&#39;?&#39;</code> Matches any single character.</li> <li><code>&#39;*&#39;</code> Matches any sequence of cha...
0
{ "code": "class Solution {\npublic:\n int substringMatch(int l,int h,int i,string &s,string &p) {\n int l1=s.size(),j=l,x=i-1;\n for(;i<l1;i++) {\n int k=i;\n while(k<l1 && (s[k]==p[j] || p[j]=='?') ) {k++;j++;} \n \n if(j==h){x=k;break;}\n else if(k==l...
44
<p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>&#39;?&#39;</code> and <code>&#39;*&#39;</code> where:</p> <ul> <li><code>&#39;?&#39;</code> Matches any single character.</li> <li><code>&#39;*&#39;</code> Matches any sequence of cha...
0
{ "code": "class Solution {\npublic:\n int substringMatch(int l,int h,int i,string &s,string &p) {\n int l1=s.size(),j=l,x=i-1;\n for(;i<l1;i++) {\n int k=i;\n while(k<l1 && (s[k]==p[j] || p[j]=='?') ) {k++;j++;} \n \n if(j==h){x=k;break;}\n else if(k==l...
44
<p>Given an input string (<code>s</code>) and a pattern (<code>p</code>), implement wildcard pattern matching with support for <code>&#39;?&#39;</code> and <code>&#39;*&#39;</code> where:</p> <ul> <li><code>&#39;?&#39;</code> Matches any single character.</li> <li><code>&#39;*&#39;</code> Matches any sequence of cha...
0
{ "code": "class Solution {\npublic:\n bool isMatch(string& s, string& p) {\n bool *dp = new bool[s.size()+1];\n bool *nextDp = new bool[s.size()+1];\n fill_n(dp, s.size()+1, false);\n fill_n(nextDp, s.size()+1, false);\n dp[0] = true;\n if(p.size() == 0) return s.size() =...