Convert the integer to string, then reverse the string
reversed_str = str(n)[::-1]
# If the input was negative, keep the negative sign in front
if n < 0:
# Remove the negative sign from the reversed string, then re-add it
reversed_int = -int(reversed_str[:-1])
else:
reversed_int = int(reversed_str)
return reversed_int
def reverse_integer(n):
Convert the integer to string, then reverse the string