Skip to content

Commit

Permalink
- Bruh. So poorly worded problem.
Browse files Browse the repository at this point in the history
  • Loading branch information
PG-Momik committed Oct 6, 2024
1 parent 5cf414a commit e1538f3
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions _011_plusOne.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* @param {number[]} digits
* @return {number[]}
*/
var plusOne = function (digits) {
return doThisShitRecursively(digits, (digits.length)-1);
};

function doThisShitRecursively(digits, i){
if (i < 0) {
digits.unshift(1);
return digits;
}

if (digits[i] === 9) {
digits[i] = 0;
return doThisShitRecursively(digits, i - 1);
}

digits[i]++;

return digits;
}

0 comments on commit e1538f3

Please sign in to comment.