Plus One
Question (LC.66)
Example
I: [1, 2, 3]
O: [1, 2, 4]
I: [9, 9, 9]
O: [1, 0, 0, 0]Analysis
Brute Force Approach:
linear scan the array from right to left
keep track of a carry
check if (carry == 1) in the end
then create a new array with size + 1Code w/ side effects
Code w/o side effects
Last updated