Skip to content

Commit 0241133

Browse files
committed
added Fucntion
1 parent 944375d commit 0241133

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Plus One/code.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* @param {number[]} digits
3+
* @return {number[]}
4+
*/
5+
var plusOne = function(digits) {
6+
for(let i =digits.length-1; i>=0; i--){
7+
if(digits[i]!==9){
8+
digits[i]++
9+
return digits
10+
}
11+
else{
12+
digits[i]=0;
13+
}
14+
}
15+
digits.unshift(1);
16+
return digits
17+
};

0 commit comments

Comments
 (0)