Array Sum Time : Space : 12345678910111213141516171819202122232425262728vector<int> Solution::addArrays(vector<int> &A, vector<int> &B) { reverse(begin(A), end(A)); reverse(begin(B), end(B)); int p = 0, carry = 0; vector<int> res; while(p < A.size() and p < B.size()) { int now = carry + A[p] + B[p]; res.push_back(now % 10); carry = now / 10; p += 1; } while(p < A.size()) { int now = carry + A[p]; res.push_back(now % 10); carry = now / 10; p += 1; } while(p < B.size()) { int now = carry + B[p]; res.push_back(now % 10); carry = now / 10; p += 1; } reverse(begin(res), end(res)); return res;}