Java | LinkedList | 10 lines | Beats > 97%
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: $$O(max(N,logK))$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(max(N,logK))$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n  public List<Integer> addToArrayForm(int[] num, int k) {\n    var ans = new LinkedList<Integer>();\n    var carry = 0;\n\n    for (var i = num.length - 1; i >= 0 || k > 0 ; i--, k /= 10) {\n      var a = i >= 0 ? num[i] : 0;\n      var b = k > 0 ? k % 10 : 0;\n      var c = a + b + carry;\n\n      ans.addFirst(c % 10);\n      carry = c / 10;\n    }\n    if (carry > 0) ans.addFirst(carry);\n    return ans;\n  }\n}\n```
['Doubly-Linked List', 'Java']