Add 1 to the number
Problem to add one to the list.
Example-1:
Input : n = [ 1, 2, 4] Output : [1, 2, 5]
Example-2:
Input : n = [ 9, 9, 9] Output : [1, 0, 0, 0]
Solution
n = [ 1, 2, 4] a = [str(x) for x in n] b = "".join(a) b = int(b)+1 c = [int(y) for y in str(b)] print(c)
Output
[1, 2, 5]