✅ JAVA ✅ Fastest --> 0ms Runtime easy and elegant Solution
\nfor (int i = digits.length - 1; i >= 0; i--) {\n\tif (digits[i] < 9) {\n\t\tdigits[i]++;\n\t\treturn digits;\n\t}\n\tdigits[i] = 0;\n}\n\ndigits = new int[dig
```\nfor (int i = digits.length - 1; i >= 0; i--) {\n\tif (digits[i] < 9) {\n\t\tdigits[i]++;\n\t\treturn digits;\n\t}\n\tdigits[i] = 0;\n}\n\ndigits = new int[digits.length + 1];\ndigits[0] = 1;\nreturn digits;\n```\n\n\nexplanation\n\n```\nfor (int i = digits.length - 1; i >= 0; i--) {\n\tif (digits[i] < 9) {\n\t\tdigits[i]++;\n\t\treturn digits;\n\t\t// starting from extreme right--> if array[i] is less than 9 means can be added with 1\n\t\t// i.e. [ 5,8 ]-->[ 5,9 ] or\n\t\t//      [ 9,4 ]-->[ 9,5 ] or\n\t\t//      [ 6,0 ]-->[ 6,1 ]\n\t\t// and will directly return array\n\t}\n\tdigits[i] = 0;\n\t// if array[i] is not less than 9, means it have to be 9 only then digit is changed to 0,\n\t// and we again revolve around loop to check for number if less than 9 or not\n\t// i.e. [ 5,9 ]-->[ 5,0 ]-loop->[ 6,0 ] or\n\t//      [ 1,9,9 ]-->[ 1,9,0 ]-loop->[ 1,0,0 ]-loop->[ 2,0,0 ]\n\t// and will directly return array\n}\n\n// if all number inside array are 9\n// i.e. [ 9,9,9,9 ] than according to above loop it will become [ 0,0,0,0 ]\n// but we have to make it like this [ 9,9,9,9 ]-->[ 1,0,0,0,0 ]\n\n\n// to make like above we need to make new array of length--> n+1\n// by default new array values are set to -->0 only\n// thus just changed first value of array to 1 and return the array\n\ndigits = new int[digits.length + 1];\ndigits[0] = 1;\nreturn digits;\n```\n\n**TC O(n)\nSC O(n)**\n\n\n\n**If you have any question, feel free to ask. If you like the solution or the explanation, Please UPVOTE !**
['Java']