easy solution
Intuition\nThe problem can be reduced to a simple addition of two numbers: one represented as an array (num) and the other as an integer (k). We need to simulat
# Intuition\nThe problem can be reduced to a simple addition of two numbers: one represented as an array (`num`) and the other as an integer (`k`). We need to simulate this addition starting from the least significant digits (rightmost elements) and handling carry over.\n\n# Approach\n1. Start from the rightmost digit of the array (`num`) and the least significant digit of `k`.\n2. Add the corresponding digits from `num` and `k`, along with any carry.\n3. If `num` has more digits than `k`, continue processing `num`.\n4. If `k` has more digits than `num`, insert digits at the beginning of `num`.\n5. Handle carry as needed throughout the process.\n6. Return the modified `num` array.\n\n# Complexity\n- **Time complexity**: $$O(\\max(n, \\log{k}))$$  \n   Where `n` is the size of `num`, and `log{k}` is the number of digits in `k`.\n  \n- **Space complexity**: $$O(1)$$  \n   In-place modifications to `num` (except for inserting digits, which happens at the front but is not considered additional space).\n\n# Code\n```cpp\nclass Solution {\npublic:\n    vector<int> addToArrayForm(vector<int>& num, int k) {\n        int carry = 0;\n        int i = num.size() - 1;\n        \n        while (k || i >= 0 || carry) {\n            int digit = k % 10;\n\n            if (i >= 0) {\n                num[i] += digit + carry;\n                carry = num[i] / 10;\n                num[i] %= 10;\n                i--;\n            } else {\n                int sum = digit + carry;\n                carry = sum / 10;\n                num.insert(num.begin(), sum % 10);\n            }\n\n            k /= 10;\n        }\n        return num;\n    }\n};\n```
['Array', 'Math', 'C++']