[Java/Python 3] 6 liner w/ comment and analysis
Note:\n\nI read several other java solutions, and found ArrayList.add(0, K % 10) was used, and it is not O(1) but O(n) instead. \n\nLinkedList.add(0, i) or offe
# **Note:**\n\nI read several other java solutions, and found `ArrayList.add(0, K % 10)` was used, and it is not `O(1)` but `O(n)` instead. \n\n`LinkedList.add(0, i)` or `offerFirst(i)` is `O(1)`.\n\nCorrect me if I am wrong.\n\n```java\n    public List<Integer> addToArrayForm(int[] A, int K) {\n        LinkedList<Integer> ans = new LinkedList<>();\n        for (int i = A.length - 1; K > 0 || i >= 0; --i, K /= 10) { // loop through A and K, from right to left.\n            K += i >= 0 ? A[i] : 0; // Use K as carry over, and add A[i].\n            ans.offerFirst(K % 10); // add the least significant digit of K.\n        }\n        return ans;\n    }\n```\t\n```python\n    def addToArrayForm(self, A: List[int], K: int) -> List[int]:\n        ans, i = [], len(A) - 1\n        while K > 0 or i >= 0:\n            K, rmd = divmod(K + (A[i] if i >= 0 else 0), 10)\n            ans.append(rmd)\n            i -= 1\n        return reversed(ans)\n```\n**Analysis:**\n\n**Time & space: O(n + logK)**, where n = A.length.
[]