C++✅✅ | 0ms Faster Solution⏳ | O(1) Space Complexity | Clean and Understandable😇
Code\n# PLEASE DO UPVOTE !\nCONNECT WITH ME ON LINKEDIN : https://www.linkedin.com/in/kunal-shaw-/\n\nclass Solution {\npublic:\n    vector<int> addToArrayForm(
# Code\n# **PLEASE DO UPVOTE !**\n**CONNECT WITH ME ON LINKEDIN : https://www.linkedin.com/in/kunal-shaw-/**\n```\nclass Solution {\npublic:\n    vector<int> addToArrayForm(vector<int>& num, int k) {\n        int n=num.size();\n        int c=0;\n        int i;\n        for(i=n-1;i>=0 or k>0;i--){\n            int r=k%10;\n            k/=10;\n            if(i>=0){\n                int res=num[i]+r+c;\n                num[i]=res%10;\n                c=res/10;\n            }\n            else{\n                int res=r+c;\n                num.insert(num.begin(),res%10);\n                c=res/10;\n            }\n\n        }\n        if(c>0){\n            num.insert(num.begin(),c);\n        }\n        return num;\n    }\n};\n```\n![memer-cat.jpg](https://assets.leetcode.com/users/images/dfc2018d-01d8-43da-9889-af2896179f15_1675779280.3429081.jpeg)
['Math', 'C++']