Stack Bash - Master data structures and algorithms

Add one to a number represented by an array

Easy
Consider 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:
  1. add_array([1, 9, 9]) returns [2, 0, 0]
  2. add_array([3, 2]) returns [3, 3]
  3. add_array([9, 9]) returns [1, 0, 0]

Solution

7 Essential Arrays Coding Interview Problems

Master Arrays by trying the coding challenges below.
  1. 1.Trade stock onceEasy
  2. 2.AdditionEasy
  3. 3.Find the smallestEasy
  4. 4.Sort colorsMedium
  5. 5.Reorganize numbersHard
  6. 6.Maximum subarrayHard
  7. 7.Container of waterHard