The array-form of an integer num is an array representing its digits in left to right order.


	For example, for num = 1321, the array form is [1,3,2,1].


Given num, the array-form of an integer, and an integer k, return the array-form of the integer num + k.

&nbsp;
Example 1:

Input: num = [1,2,0,0], k = 34
Output: [1,2,3,4]
Explanation: 1200 + 34 = 1234


Example 2:

Input: num = [2,7,4], k = 181
Output: [4,5,5]
Explanation: 274 + 181 = 455


Example 3:

Input: num = [2,1,5], k = 806
Output: [1,0,2,1]
Explanation: 215 + 806 = 1021


&nbsp;
Constraints:


	1 &lt;= num.length &lt;= 104
	0 &lt;= num[i] &lt;= 9
	num does not contain any leading zeros except for the zero itself.
	1 &lt;= k &lt;= 104


class Solution:
    def addToArrayForm(self, num: List[int], k: int) -> List[int]:
        return list(str(int("".join(map(str,num)))+k))
class Solution {
    public List<Integer> addToArrayForm(int[] num, int k) {
        List<Integer> res = new ArrayList<>();
        
        int i = num.length;
        while(--i >= 0 || k > 0) {
            if(i >= 0)
                k += num[i];
            
            res.add(k % 10);
            k /= 10;
        }
        Collections.reverse(res);
        
        return res;
    }
}
Time: O(max(n,Log k))  Space: O(1)

class Solution {
public:
    vector<int> addToArrayForm(vector<int>& num, int k) {
        vector<int> res;
        int i=size(num)-1;
        int c=0,sum;
        while(i>=0){
            sum=num[i]+k%10+c;
            res.push_back(sum%10);
            c=sum/10;
            k/=10;i--;
        }
        while(k){
            sum=k%10+c;
            res.push_back(sum%10);
            c=sum/10;
            k/=10;
        }
        if(c)
            res.push_back(c);
        reverse(begin(res),end(res));
        return res;
    }
};

--> Approach 2 

class Solution {
public:
    vector<int> addToArrayForm(vector<int>& num, int k) {
        vector<int> res;
        int i=size(num)-1;
        int sum;
        while(i>=0){
            sum=num[i]+k;
            res.push_back(sum%10);
            k=sum/10;i--;
        }
        while(k){
            res.push_back(k%10);
            k/=10;
        }
        reverse(begin(res),end(res));
        return res;
    }
};
var addToArrayForm = function(num, k) {
    const length = num.length;
    let digit = 0, index = length-1;
    while(k > 0 || digit > 0) {
        if(index >= 0) {
            digit = digit + num[index] + k%10;
            num[index] = digit%10;
        }
        else {
            digit = digit + k%10;
            num.unshift(digit%10);
        }
        digit = digit > 9 ? 1 : 0;
        k = parseInt(k/10);
        index--;
    }
    if(digit) num.unshift(digit);
    return num;
};
Add to Array-Form of Integer