Suppose we have an array of integers, say A. A will hold n elements, and they are non-negative. The whole array A is representing one large number. So if A = [5, 3, 2, 4] is given, it indicates the number 5324. We have to take that array A, then increase the number by 1, and again return the number like an array as given. So after increasing A will be [5, 3, 2, 5]
To solve this, we will follow these steps.
Let us see the following implementation to get a better understanding −
class Solution(object): def plusOne(self, digits): """ :type digits: List[int] :rtype: List[int] """ num = "" for i in digits: num +=str(i) num = int(num) num+=1 num = str(num) ans =  for i in num: ans.append(int(i)) return ans digits = [5,3,2,4] ob1 = Solution() print(ob1.plusOne(digits))
digits = [5,3,2,4]