We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 47dcd59 commit 0b21c52Copy full SHA for 0b21c52
0066-plus-one/0066-plus-one-04-18-2025-00-39-00.js
@@ -0,0 +1,18 @@
1
+/**
2
+ * @param {number[]} digits
3
+ * @return {number[]}
4
+ */
5
+var plusOne = function(digits) {
6
+ let carry = 1
7
+ for(let i = digits.length - 1;i >= 0;i--){
8
+ const current = digits[i]
9
+ const sum = carry + current
10
+ carry = Math.floor(sum / 10)
11
+ digits[i] = sum % 10
12
+ }
13
+
14
+ if(carry > 0){
15
+ digits.unshift(carry)
16
17
+ return digits
18
+};
0 commit comments