JAVA 100 % FASTER 🔥🚀|| STEP BY STEP EXPLAINED SOLUTION
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->O(N)\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->O(N)\n![Screenshot_20230205_171246.png](https://assets.leetcode.com/users/images/15360baf-39c0-45e7-b2e2-b8d6d07813d5_1682477226.014943.png)\n\n\n# Code\n```\nclass Solution {\n    public int[] plusOne(int[] digits) {\n        int n = digits.length;\n        // Starting from the least significant digit (i.e., the last element of the array)\n        for (int i = n - 1; i >= 0; i--) {\n            // If the current digit is less than 9, we can add 1 to it and return the updated array\n            if (digits[i] < 9) {\n                digits[i]++; // Add 1 to the current digit\n                return digits; // Return the updated array\n            }\n            // If the current digit is 9, we set it to 0 and continue with the next digit\n            else {\n                digits[i] = 0; // Set the current digit to 0\n            }\n        }\n        // If we reach here, it means all digits were 9, so we need to create a new array with one more element\n        int[] result = new int[n + 1]; // Create a new array with length n + 1\n        result[0] = 1; // Set the first element to 1, since all other elements are 0 by default\n        return result; // Return the new array\n    }\n}\n\n```
['Java']