Optimized Solution in C++
Intuition\nWe can optimize the solution to avoid the integer conversion and make it more efficient. Instead of computing the sum of the input integer and k digi
# Intuition\nWe can optimize the solution to avoid the integer conversion and make it more efficient. Instead of computing the sum of the input integer and k digit by digit, we can directly add k to the least significant digit of the input integer and carry over the result to the higher digits. This way, we can build the array-form of the sum digit by digit, without having to convert the input integer to an integer.\n\n\n# Code\n```\nclass Solution {\npublic:\n    vector<int> addToArrayForm(vector<int>& num, int k) {\n    vector<int> res;\n    int carry = k;\n    \n    for (int i = num.size() - 1; i >= 0 || carry > 0; i--) {\n        if (i >= 0) {\n            carry += num[i];\n        }\n        res.push_back(carry % 10);\n        carry /= 10;\n    }\n    \n    reverse(res.begin(), res.end());\n    return res;\n}\n};\n```
['Array', 'C++']