Plus One Problem

Overview

In this particular LeetCode problem, Plus One, I would have to approach it with a crafty approach. The problem states

Here is an example for a better understanding.

Let's Dive in.

Since we are targeting the end of the array. My first approach was to reverse loop through the array.

Since we can't have double-digit numbers I targeted 9. If the current digit does not equal the value or type of 9 increments by one

Along with incrementing the number, I decided to return the digit.

I created a SafeNet for 0. If the current number = 0 and if the index is at the current position of 0. Take the array add 1 to it and return the digits.

Thanks for reading.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store