36: Add one

Given an array of integers. The array represents a non-negative integer, add one to this number

Note: the most significant digit is the first item of the array

 

Example 1

Input: [1, 2, 3, 4]

Output: [1, 2, 3, 5]

Explanation: [1, 2, 3, 4] = 1234, 1234 + 1 = 1235

Example 2

Input: [1, 9]

Output: [2, 0]
Difficulty:Easy
Topic:Array
Problem #:36