✅ 🔥 0 ms Runtime Beats 100% User 🔥|| Step By Steps Solution ✅ ||  Easy to Understand  ✅🔥 ||
\u2705  IF YOU LIKE THIS SOLUTION, PLEASE UPVOTE AT THE END \u2705 :\n\n### Intuition :\nWhen you want to increment a large number that is represented as an arr
\u2705  IF YOU LIKE THIS SOLUTION, PLEASE UPVOTE AT THE END \u2705 :\n\n### Intuition :\nWhen you want to increment a large number that is represented as an array of its digits (like `[1, 2, 3]` for the number 123), you need to consider how addition works digit by digit. If the last digit is less than 9, you can simply add one to it. If it\'s 9, adding one will make it 10, so you set that digit to 0 and carry over the 1 to the next digit to the left. If you carry over all the way to the front and still have a carry (like going from `[9]` to `[1, 0]`), you need to add a new digit at the front.\n\n### Approach :\n1. Start from the last digit of the array.\n2. Try to add 1 to that digit.\n3. If the digit becomes 10, set it to 0 and carry 1 to the next digit.\n4. Repeat until you either run out of digits or finish carrying.\n5. If there\'s still a carry after processing all digits, add a new digit `1` at the front of the array.\n\n### Solving Steps :\n1. Loop through the array from the last digit to the first.\n2. Add 1 to the current digit.\n3. Check if the digit is now 10.\n4. If it is, set that digit to 0 and continue to the next digit.\n5. If you finish the loop and still have a carry, insert `1` at the start of the array.\n6. Return the modified array.\n\n![WhatsApp Image 2024-10-25 at 11.38.29.jpeg](https://assets.leetcode.com/users/images/8e7a65d5-685d-4027-b78c-969f2dc7d863_1729836651.7045465.jpeg)\n\n### Code Implementations :\n\n#### Python 3 :\n```python\nfrom typing import List\n\nclass Solution:\n    def plusOne(self, digits: List[int]) -> List[int]:\n        n = len(digits)\n        for i in range(n - 1, -1, -1):\n            if digits[i] < 9:\n                digits[i] += 1\n                return digits\n            digits[i] = 0\n        return [1] + digits\n\n```\n\n#### Java :\n```java\npublic class Solution {\n    public int[] plusOne(int[] digits) {\n        int n = digits.length;\n        for (int i = n - 1; i >= 0; i--) {\n            if (digits[i] < 9) {\n                digits[i]++;\n                return digits;\n            }\n            digits[i] = 0;\n        }\n        int[] result = new int[n + 1];\n        result[0] = 1;\n        return result;\n    }\n}\n```\n\n#### C++ :\n```cpp\n#include <vector>\n\nclass Solution {\npublic:\n    std::vector<int> plusOne(std::vector<int>& digits) {\n        int n = digits.size();\n        for (int i = n - 1; i >= 0; i--) {\n            if (digits[i] < 9) {\n                digits[i]++;\n                return digits;\n            }\n            digits[i] = 0;\n        }\n        digits.insert(digits.begin(), 1);\n        return digits;\n    }\n};\n```\n\n### Summary :\nThis method allows you to increment a large number represented as an array of digits effectively, handling cases where digits overflow from 9 to 0 by carrying over to the next digit.
['Array', 'Math', 'C++', 'Java', 'Python3']