66. Plus One
\n# Code\n\nclass Solution {\n    public int[] plusOne(int[] digits) {\n        // Start from the last digit and iterate backwards\n        for (int i = digits.
\n# Code\n```\nclass Solution {\n    public int[] plusOne(int[] digits) {\n        // Start from the last digit and iterate backwards\n        for (int i = digits.length - 1; i >= 0; i--) {\n            // If the current digit is less than 9, increment it and return the array\n            if (digits[i] < 9) {\n                digits[i]++;\n                return digits;\n            }\n            // If the current digit is 9, set it to 0\n            digits[i] = 0;\n        }\n\n        // If all digits were 9, create a new array with an extra length and set the first element to 1\n        int[] newDigits = new int[digits.length + 1];\n        newDigits[0] = 1;\n        return newDigits;\n    }\n}\n\n```
['Java']