Number reverse Problem Solution
sujith3179 opened this issue · comments
The solution for Number reverse problem is failing few test cases (Giving wrong answer) @pankajkompella
Is it the C code or Python code that's erroneous?
I think both the codes are not passing all test cases
The negative numbers are not handled. Check out my python solution for reference.
Code :
n = int(input())
def reverse(n):
rev = 0
while(n > 0):
a = n % 10
rev = rev * 10 + a
n = n // 10
return rev
if n >=0:
print(reverse(n))
else:
reverse_num = reverse(n*(-1))
print(-reverse_num)