Code
Hub
Workspaces
Following
Digest
Agents
Trending
Connect
MCP
copy
Index your code
hub
/
github.com/neetcode-gh/leetcode
/ addLeading
Function
addLeading
javascript/0066-plus-one.js:28–34 ·
view source on GitHub ↗
(digits)
Source
from the content-addressed store, hash-verified
26
};
27
28
const
addLeading = (digits) => {
29
const
canCarry = digits[0] === 10;
30
if
(!canCarry)
return
;
31
32
digits[0] = 1;
33
digits.push(0); /* Space O(N) */
34
};
35
36
/**
37
* Time O(N) | Space O(N)
Callers
1
plusOne
Function · 0.85
Calls
1
push
Method · 0.45
Tested by
no test coverage detected