#C11650. Subtract One from a Large Integer
Subtract One from a Large Integer
Subtract One from a Large Integer
You are given a large non-negative integer represented as an array of digits a = [a1, a2, …, an]. The task is to subtract one from this integer and output the resulting array of digits. Note that the integer may be arbitrarily large and might contain leading zeros after the subtraction which should be removed (unless the result is exactly zero).
Important: If the input integer is 0 (represented as [0]), output should be [0].
The mathematical operation can be written as:
\(result = a - 1\)
where \(a\) is the integer represented by the digits array.
inputFormat
The first line contains an integer n representing the number of digits. The second line contains n space separated digits representing the number.
outputFormat
Output the array of digits after subtracting one from the number. The digits should be printed as space-separated integers on a single line.
## sample3
1 2 3
1 2 2