Add one to a number represented by an array
EasyConsider an array of positive integers that represents a number.
For example,
[2, 4, 5]
represents the number 245
.Write a function that returns an array of numbers of the input + 1.
Some examples:
add_array([1, 9, 9])
returns[2, 0, 0]
add_array([3, 2])
returns[3, 3]
add_array([9, 9])
returns[1, 0, 0]
Solution
6 Essential Arrays Coding Interview Problems
Master Arrays by trying the coding challenges below.
- 1.Trade stock onceEasy
- 2.AdditionEasy
- 3.Find the smallestEasy
- 4.Reorganize numbersHard
- 5.Maximum subarrayHard
- 6.Container of waterHard