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

6 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.Reorganize numbersHard
  5. 5.Maximum subarrayHard
  6. 6.Container of waterHard

Want to confidently pass your next coding interview?

Stack Bash helps new and veteran software engineers master data structures and algorithms for technical interviews.