DEV Community

Cover image for [Devmates.co] Add One by ๐Ÿš•Bolt
Alex Wawl ๐Ÿผ
Alex Wawl ๐Ÿผ

Posted on

[Devmates.co] Add One by ๐Ÿš•Bolt

Hello๐Ÿ‘‹,
My name is Alex and I'm maker of Devmates.co. ๐Ÿ˜Š

We are resolving daily coding problems which asked by top tech companies together. We share our solutions, give some help if anyone stuck, support each other and just hangout together in the internet. ๐Ÿปโ˜•๏ธ๐Ÿ’ฌ

I get this problem from our members or just searching them in the internet(leetcode forums, Glassdoor, teamblind, etc.). Sometimes this problem can be very easy, sometimes too ๐Ÿ‘ทโ€โ™‚๏ธhard, everything depends on skills but we are trying to resolve all of them and Have Fun. ๐Ÿ™Œ

Today I want to share problem which was asked by ๐Ÿš•Bolt.

Problem:

Given a non-empty array of digits representing a non-negative integer and each element in the array contain a single digit.

Add one (1) to this integer and return it as array.

You may assume the integer does not contain any leading zero, except the number 0 itself.

Note: Converting to the integer and back to the array is not allowed.

Example:

Input: [3,2,1]
Output: [3,2,2]

Input: [9,9,9]
Output: [1,0,0,0]

Input: [5,6,9]
Output: [5,7,0]

๐Ÿ™Œ Don't hesitate to share your solutions directly on devmates.co

Latest comments (0)