✅ EASY C++ SOLUTION ☑️
PLEASE UPVOTE MY SOLUTION IF YOU LIKE IT\n# CONNECT WITH ME\n### https://www.linkedin.com/in/pratay-nandy-9ba57b229/\n#### https://www.instagram.com/pratay_nand
# **PLEASE UPVOTE MY SOLUTION IF YOU LIKE IT**\n# **CONNECT WITH ME**\n### **[https://www.linkedin.com/in/pratay-nandy-9ba57b229/]()**\n#### **[https://www.instagram.com/_pratay_nandy_/]()**\n\n# Approach\n### Explanation:\n\n1. The function iterates through the digits in reverse order (`j` starts from the rightmost digit).\n\n2. If the current digit is less than 9, it means we can simply increment it and return the updated vector. The function exits at this point.\n\n3. If the current digit is 9, it is set to 0, and the loop continues to the next digit.\n\n4. If the loop completes without returning, it means all digits were 9, and a new digit \'1\' needs to be added at the beginning of the vector.\n\n5. A new vector `num` is initialized with the value \'1\'.\n\n6. The original digits are then appended to the `num` vector.\n\n7. The final result vector `num` is returned.\n\nThis code essentially emulates the process of adding one to a non-negative integer represented by an array of digits. It handles cases where there might be a carry from the least significant digit to the most significant digit.\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:**0(N)**\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:**0(N)**\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n![upvote2.png](https://assets.leetcode.com/users/images/6198d926-527c-42f7-a663-aaf8d62ed44c_1704980133.0159707.png)\n\n\n# Code\n```\nclass Solution {\npublic:\n\n    vector<int> plusOne(vector<int>& digits) {\n\n        for(int j=digits.size()-1;j>=0;j--){\n           if(digits[j]<9){\n               digits[j]++;\n               return digits;\n           }\n            digits[j]=0;\n        }\n        vector<int>num;\n        num.push_back(1);\n\n        for(int i =0;i<digits.size();i++)\n        {\n        num.push_back(digits[i]);\n        }\n        return num;\n    \n    }\n};\n```
['Array', 'Math', 'C++']