📌📌Python3 || ⚡268 ms, faster than 96.60% of Python3
\n\nclass Solution:\n    def addToArrayForm(self, num: List[int], k: int) -> List[int]:\n        if not num:\n            return [int(d) for d in str(k)]\n     
![image](https://assets.leetcode.com/users/images/56149966-d41d-41e2-9bc6-5ee3fcc51014_1676427091.1014879.png)\n```\nclass Solution:\n    def addToArrayForm(self, num: List[int], k: int) -> List[int]:\n        if not num:\n            return [int(d) for d in str(k)]\n        carry = 0\n        res = []\n        for i in range(len(num)-1, -1, -1):\n            total = num[i] + carry + (k % 10)\n            carry = total // 10\n            res.append(total % 10)\n            k //= 10\n        while k > 0:\n            total = carry + (k % 10)\n            carry = total // 10\n            res.append(total % 10)\n            k //= 10\n        if carry > 0:\n            res.append(carry)\n        return res[::-1]\n```\nThe main idea of the function is to simulate the addition process for two numbers: the input num and the input k. The addition is performed digit by digit, from right to left, while keeping track of the carry from one digit to the next. The function appends each resulting digit to the res list and returns it at the end.\nHere\'s a step by step description of the code:\n\n1. Define a function addToArrayForm that takes in a list of integers num and an integer k, and returns a list of integers.\n1. Check if num is an empty list. If so, convert k to a list of integers and return it.\n1. Initialize variables carry and res to 0 and an empty list, respectively.\n1. Loop over num in reverse order using the range function. At each iteration:\n\t1. \tCalculate the sum of the current digit of num, the corresponding digit of k, and the carry using the modulo operator (%).\n\t1. \tUpdate the carry by dividing the total by 10 using integer division (//).\n\t1. \tAppend the remainder of the total (i.e., total % 10) to res.\n\t1. \tUpdate k by dividing it by 10 using integer division (//).\n1. Loop over k while it is greater than 0. At each iteration:\n\t1. Calculate the sum of the current digit of k and the carry using the modulo operator (%).\n\t1. Update the carry by dividing the total by 10 using integer division (//).\n\t1. Append the remainder of the total (i.e., total % 10) to res.\n\t1. Update k by dividing it by 10 using integer division (//).\n1. If the final carry value is greater than 0, append it to res.\n1. Return the reversed list res.
['Python', 'Python3']