n
is negative or positive.x
to a string for easy insertion.n
is positive:
a. Iterate through the digits of n
.
b. If the current digit is less than x
, insert x
before this digit and return the new string.
c. If no such digit is found, append x
at the end.n
is negative:
a. Iterate through the digits of n
, starting from index 1.
b. If the current digit is greater than x
, insert x
before this digit and return the new string.
c. If no such digit is found, append x
at the end.