Easy & Simple Solution In Java || Sum and Carry Technique 💥👍
Intuition\nsum of last numbers and carry and add to the ans and reverse it.\n\n# Approach\n1. make a list name as a ans.\n2. loop will start begin grom num.leng
# Intuition\nsum of last numbers and carry and add to the ans and reverse it.\n\n# Approach\n1. make a list name as a ans.\n2. loop will start begin grom num.length-1 to end i>=0 or k!=0.\n3. make sum and carry the value.\n4. reverse the ans liast and returrn it.\n\n# Complexity\n- Time complexity:\nO(n)\n\n- Space complexity:\nO(n)\n\n# Code\n```\nclass Solution {\n    public List<Integer> addToArrayForm(int[] num, int k) {\n        int sum,carry=0;\n        ArrayList<Integer> ans = new ArrayList<>();\n        for(int i=num.length-1;i>=0 || k!=0;i--){\n            if(i>=0){\n                sum = (k%10) + num[i] + carry;\n            }else{\n                sum = (k%10) + carry;\n            }\n            k=k/10;\n            carry = sum/10;\n            int result = sum%10;\n            ans.add(result);\n        }\n        if(carry>0){\n            ans.add(carry);\n        }\n        int i=0;\n        int j= ans.size()-1;\n        int temp;\n        while(i<j){\n            temp = ans.get(i);\n            ans.set(i,ans.get(j));\n            ans.set(j,temp);\n            i++;\n            j--;\n        }\n        return ans;\n    }\n}\n```
['Array', 'Math', 'Java']