✅Java Simple Solution || ✅Runtime 0ms || ✅ Beats100%
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)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public int[] plusOne(int[] digits) {\n         \n        int i = 0;\n        while (i <= digits.length - 1 && digits[digits.length - 1 - i] == 9) {\n            i++;\n        }\n\n        int[] output = (digits.length == i) ? new int[digits.length + 1] : new int[digits.length];\n\n        if (digits.length == i) {\n            output[0] = 1;\n        } else {\n\n            for (int j = 0; j <= digits.length - i - 1; j++) \n            {\n                output[j] = digits[j];\n            }\n\n            output[digits.length - 1 - i] = digits[digits.length - i - 1] + 1;\n        }\n        return output;\n    }\n}\n```\n\n\n## For additional problem-solving solutions, you can explore my repository on GitHub: [GitHub Repository](https://github.com/ahmedna126/java_leetcode_challenges)\n\n\n![e78315ef-8a9d-492b-9908-e3917f23eb31_1674946036.087042.jpeg](https://assets.leetcode.com/users/images/f7abc399-3a52-4e17-850a-9fc8984ee6c9_1692645882.9655104.jpeg)\n
['Java']