"multiply strings" Code Answer's

You're definitely familiar with the best coding language C++ that developers use to develop their projects and they get all their queries like "multiply strings" answered properly. Developers are finding an appropriate answer about multiply strings related to the C++ coding language. By visiting this online portal developers get answers concerning C++ codes question like multiply strings. Enter your desired code related query in the search bar and get every piece of information about C++ code related question on multiply strings. 

multiply strings

By Lucky LlamaLucky Llama on Oct 09, 2020
string Solution::multiply(string A, string B) 
{    
  vector<int> arr(A.size()+B.size(),0);    
  for(int i=A.size()-1;i>=0;i--)    
  {        
    for(int j =B.size()-1;j>=0;j--)        
    {            
      int x = (B[j]-'0')*(A[i]-'0')+arr[i+j+1];           
      arr[i+j+1] = x%10;            
      arr[i+j] += x/10;        
    }    
  }    
  int i=0;    
  while(i<arr.size())    
  {        
    if(arr[i]!=0)            
      break;            
    i++;    
  }                
  if(i == arr.size())        
    return "0";                
  string s = "";        
  for(int j=i;j<arr.size();j++)        
    s += to_string(arr[j]);            
  return s;    
}

Source: www.interviewbit.com

Add Comment

1

All those coders who are working on the C++ based application and are stuck on multiply strings can get a collection of related answers to their query. Programmers need to enter their query on multiply strings related to C++ code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about multiply strings for the programmers working on C++ code while coding their module. Coders are also allowed to rectify already present answers of multiply strings while working on the C++ language code. Developers can add up suggestions if they deem fit any other answer relating to "multiply strings". Visit this developer's friendly online web community, CodeProZone, and get your queries like multiply strings resolved professionally and stay updated to the latest C++ updates. 

C++ answers related to "multiply strings"

View All C++ queries

C++ queries related to "multiply strings"

Browse Other Code Languages

CodeProZone