How to solve this question in c++ please explain a bit by writing some code also
Https://online.codingblocks.com/app/player/58724/content/27238/4820/code-challenge
EG:
4
1 0 2 9
5
3 4 5 6 7

start adding from rightmost element
take care of carry
sum like u sum in basic mathematics
and display answer as per the format
I have understood the question but dont know how to solve using c++ I have problem in implementation
will pseudo code help u understand it ?
i can make the pseudo code
Yes please…
vector<int> a, b
// input array
i= a.size() ,j= b.size();
while( i >=0 or j >=0 ) {
int sum = (i >=0 ? a[i] : 0 ) + (j >= 0 ? b[j] : 0 ) + c;
vec.push_back(sum%10);
c = sum/10;
i-- ; j--;
}
if(c) vec.push_back(c);
reverse(vec.begin() , vec.end())
Thanks!..
1 Like