[Problem from Arrays and Strings - Plus One. Link here - https://leetcode.com/explore/learn/card/array-and-string/201/introduction-to-array/1148/ ]
Hi, I was trying to solve this problem with the current given instructions but seems like some of the key information is missing like when the digit is 9 what to do is not given in the problem. I thought if the digit is 9 move to previous element(I was traversing the array from n-1, where n = length of the array). I know it says the array stores only single digit so that's the clue that if it 9 than we can't increment it but what to do with 9?
It's only when I read the solution I got to know that if its 9 than make it 0 and if all the elements are 9 than take a new array with n+1 and make all 9 as 0 and the arr[0] as 1.
Please fix the problem else we will end up implementing wrong solution due to lack of info.
On another note, it's fun to solve these problems and I like the hints provided as they help sometimes to steer in right direction. Kudos for such simple yet brain teasing problems. :)
Cheers!