// Function to add two big numbers represented as vectors of digits. vector<int> addBigNumbers(const vector<int>& num1, const vector<int>& num2){ vector<int> result; int carry = 0; auto it1 = num1.rbegin(), it2 = num2.rbegin();
while (it1 != num1.rend() || it2 != num2.rend() || carry != 0) { int sum = carry; if (it1 != num1.rend()) sum += *it1++; if (it2 != num2.rend()) sum += *it2++; carry = sum / 10; result.push_back(sum % 10); }